LMDB_File-0.13/0000755000175600003110000000000014552575256011455 5ustar sogsoftLMDB_File-0.13/TODO0000644000175600003110000000047112422451414012126 0ustar sogsoft==== TODO ==== We will closely follow LMDB's development towards version 1.0, and accordingly adjust LMDB_File. We plan the following read-map for LMDB_File 1.0, in no particular order: - Implement the perldbmfilter(1) API? - Complete documentation - Tested multi-threading support - Complete the test harness LMDB_File-0.13/lib/0000755000175600003110000000000014552575256012223 5ustar sogsoftLMDB_File-0.13/lib/LMDB_File.pm0000644000175600003110000013403714474674455014252 0ustar sogsoftpackage LMDB_File; use 5.010000; use strict; use warnings; use Carp; require Exporter; use AutoLoader; our $VERSION = '0.13'; our $DEBUG = 0; our @ISA = qw(Exporter); our @CARP_NOT = qw(LMDB::Env LMDB::Txn LMDB::Cursor LMDB_File); our @EXPORT = qw(); our %EXPORT_TAGS = ( envflags => [qw(MDB_FIXEDMAP MDB_NOSUBDIR MDB_NOSYNC MDB_RDONLY MDB_NOMETASYNC MDB_NOMEMINIT MDB_WRITEMAP MDB_MAPASYNC MDB_NOTLS MDB_NOLOCK MDB_NORDAHEAD)], dbflags => [qw(MDB_REVERSEKEY MDB_DUPSORT MDB_INTEGERKEY MDB_DUPFIXED MDB_INTEGERDUP MDB_REVERSEDUP MDB_CREATE)], writeflags => [qw(MDB_NOOVERWRITE MDB_NODUPDATA MDB_CURRENT MDB_RESERVE MDB_APPEND MDB_APPENDDUP MDB_MULTIPLE)], cursor_op => [qw(MDB_FIRST MDB_FIRST_DUP MDB_GET_BOTH MDB_GET_BOTH_RANGE MDB_GET_CURRENT MDB_GET_MULTIPLE MDB_NEXT MDB_NEXT_DUP MDB_NEXT_MULTIPLE MDB_NEXT_NODUP MDB_PREV MDB_PREV_DUP MDB_PREV_NODUP MDB_LAST MDB_LAST_DUP MDB_SET MDB_SET_KEY MDB_SET_RANGE)], copyflags => [qw(MDB_CP_COMPACT)], error => [qw(MDB_SUCCESS MDB_KEYEXIST MDB_NOTFOUND MDB_PAGE_NOTFOUND MDB_CORRUPTED MDB_PANIC MDB_VERSION_MISMATCH MDB_INVALID MDB_MAP_FULL MDB_DBS_FULL MDB_READERS_FULL MDB_TLS_FULL MDB_TXN_FULL MDB_CURSOR_FULL MDB_PAGE_FULL MDB_MAP_RESIZED MDB_INCOMPATIBLE MDB_BAD_RSLOT MDB_BAD_TXN MDB_BAD_VALSIZE MDB_BAD_DBI MDB_LAST_ERRCODE)], version => [qw(MDB_VERSION_FULL MDB_VERSION_MAJOR MDB_VERSION_MINOR MDB_VERSION_PATCH MDB_VERSION_STRING MDB_VERSION_DATE)], ); $EXPORT_TAGS{flags} = [ @{$EXPORT_TAGS{envflags}}, @{$EXPORT_TAGS{dbflags}}, @{$EXPORT_TAGS{writeflags}}, @{$EXPORT_TAGS{copyflags}} ]; { my %seen; push @{$EXPORT_TAGS{all}}, grep {!$seen{$_}++} @{$EXPORT_TAGS{$_}} foreach keys %EXPORT_TAGS; } our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); sub AUTOLOAD { my $constname; our $AUTOLOAD; ($constname = $AUTOLOAD) =~ s/.*:://; croak "&LMDB_File::constant not defined" if $constname eq 'constant'; my ($error, $val) = constant($constname); if ($error) { croak $error; } { no strict 'refs'; *$AUTOLOAD = sub { $val }; } goto &$AUTOLOAD; } require XSLoader; XSLoader::load('LMDB_File', $VERSION); my $dbflmask = do { no strict 'refs'; my $f = 0; $f |= &{"LMDB_File::$_"}() for @{$EXPORT_TAGS{dbflags}}; $f; }; package LMDB::Env; use Scalar::Util (); use Fcntl; our %Envs; sub new { my ($proto, $path, $eflags) = @_; create(my $self); return unless $self; $eflags = { flags => ($eflags || 0) } unless ref $eflags; $eflags->{mapsize} and $self->set_mapsize($eflags->{mapsize}) and return; $eflags->{maxdbs} and $self->set_maxdbs($eflags->{maxdbs}) and return; $eflags->{maxreaders} and $self->set_maxreaders($eflags->{maxreaders}) and return; if($^O =~ /openbsd/) { # OpenBSD lacks an unified buffer cache (UBC) so LMDB only works # with MDB_WRITEMAP set when not in read-only mode $eflags->{flags} |= LMDB_File::MDB_WRITEMAP() unless $eflags->{flags} & LMDB_File::MDB_RDONLY(); } $self->open($path, $eflags->{flags}, $eflags->{mode} || 0600) and return; warn "Created LMDB::Env $$self\n" if $DEBUG; return $self; } sub Clean { my $self = shift; my $txl = $Envs{ $$self }[0] or return; if(@$txl) { Carp::carp("LMDB: Aborting $#$txl transactions in $$self."); $txl->[$#$txl]->abort; } $Envs{ $$self }[0] = []; } sub DESTROY { my $self = shift; my $txl = $Envs{ $$self } && $Envs{ $$self }[0]; if($txl and @$txl and my $topTxn = $txl->[$#$txl]) { # As every Txn references its Env this is only possible at global destruction Carp::carp("LMDB: OOPS! Destroying an active environment!"); warn("LMDB: Aborting $#$txl transactions in $$self.") if $DEBUG; $topTxn->abort; } $self->close; warn "Closed LMDB::Env $$self (remains @{[scalar keys %Envs]})\n" if $DEBUG; } sub BeginTxn { my $self = shift; $self->get_flags(my $eflags); my $tflags = shift || ($eflags & LMDB_File::MDB_RDONLY()); my $txl = $Envs{ $$self }[0]; warn "BeginTxn $$self($$), deep: ", scalar(@$txl), "\n" if $DEBUG; return $txl->[0]->SubTxn($tflags) if @$txl; LMDB::Txn->new($self, $tflags); } sub CLONE { # After a thread is created all Txns of parent thread are forgot $_->[0] = [] for values %Envs; _clone(); 1; } package LMDB::Txn; our %Txns; my %Cursors; sub new { my ($parent, $env, $tflags) = @_; my $txl = $Envs{ $$env }[0]; Carp::croak("Transaction active, should be subtransaction") if !ref($parent) && @$txl; _begin($env, ref($parent) && $parent, $tflags, my $self); return unless $self; $Txns{$$self} = { Active => 1, Env => $env, # A transaction references the environment RO => $tflags & LMDB_File::MDB_RDONLY(), }; unshift @$txl, $self; Scalar::Util::weaken($txl->[0]); warn "Created LMDB::Txn $$self in $$env\n" if $DEBUG; return $self; } sub SubTxn { my $self = shift; if($^O =~ /openbsd/) { # Needs MDB_WRITEMAP so Carp::croak("Subtransactions are unsupported in this OS"); } my $tflags = shift || 0; return $self->new($self->env, $tflags); } sub DESTROY { my $self = shift; my $td = $Txns{ $$self } or return; if($td->{Active} && !$td->{RO} && $td->{AC}) { warn "LMDB: Destroying an active transaction, commiting $$self...\n" if $DEBUG; $self->commit; } else { warn "LMDB: Destroying an active transaction, aborting $$self...\n" if $DEBUG; $self->abort; } } sub _prune { my $self = shift; my $eid = shift; if(my $txl = $Envs{ $eid } && $Envs{ $eid }[0]) { while(my $rel = shift @$txl) { my $td = delete $Txns{ $$rel }; delete $Cursors{$_} for keys %{ $td->{Cursors} }; last if $$rel == $$self; } warn "LMDB::Txn: Txns list deep: @{[scalar @$txl]}\n" if $DEBUG > 2; } warn "LMDB::Txn: $$self($$) finalized in $eid\n" if $DEBUG > 1; $$self = 0; } sub abort { my $self = shift; unless($Txns{ $$self }) { Carp::carp("Terminated transaction"); return; } my $eid = $self->_env; $self->_abort; warn "LMDB::Txn $$self aborted\n" if $DEBUG; $self->_prune($eid); } sub commit { my $self = shift; my $td = $Txns{ $$self } or Carp::croak("Terminated transaction"); Carp::croak("Not an active transaction") unless $td->{Active}; my $eid = $self->_env; $self->_commit; warn "LMDB::Txn $$self commited\n" if $DEBUG; $self->_prune($eid); } sub Flush { my $self = shift; my $td = $Txns{ $$self } or Carp::croak("Terminated transaction"); Carp::croak("Not an active transaction") unless $td->{Active}; $self->_commit; # This depends on malloc order, beware! _begin($td->{Env}, undef, $td->{RO}, my $ntxn); Carp::croak("Can't recreate Txn") unless $$ntxn == $$self; $$ntxn = 0; } sub reset { my $self = shift; my $td = $Txns{ $$self } or Carp::croak("Terminated transaction"); Carp::croak("Not a read-only transaction") unless $td->{RO}; $self->_reset if $td->{Active}; $td->{Active} = 0; } sub renew { my $self = shift; my $td = $Txns{ $$self } or Carp::croak("Terminated transaction"); $self->_reset if $td->{Active}; $self->_renew; $td->{Active} = 1; } sub OpenDB { my ($self, $name, $flags) = @_; my $options = ref($name) eq 'HASH' ? $name : { dbname => $name, flags => $flags }; LMDB_File->open($self, $options->{dbname}, $options->{flags}); } sub env { my $self = shift; $Txns{$$self} && $Txns{$$self}{Env}; } sub AutoCommit { my $self = shift; my $td = $Txns{ $$self } or Carp::croak("Terminated transaction"); my $prev = $td->{AC}; $td->{AC} = shift if(@_); $prev; } # Fast low-level dbi API sub open { my($txn, $name, $flags) = @_; $flags ||= 0; Carp::croak("Not an alive transaction") unless $Txns{ $$txn }; Carp::croak("Not the current child transaction") unless(${$Envs{ $txn->_env }[0][0]} == $$txn); _dbi_open($txn, $name, $flags & $dbflmask, my $dbi); warn "Opened dbi $dbi\n" if $dbi && $DEBUG; return $dbi; } *get = \&LMDB_File::_get; *put = \&LMDB_File::_put; *del = \&LMDB_File::_del; sub CLONE_SKIP { # All LMDB Transactions are usable only in the thread that create it 1; } package LMDB::Cursor; sub get { LMDB_File::_chkalive($Cursors{${$_[0]}}); goto &_get; } sub put { LMDB_File::_chkalive($Cursors{${$_[0]}}); goto &_put; } sub del { LMDB_File::_chkalive($Cursors{${$_[0]}}); goto &_del; } sub DESTROY { my $self = shift; return unless $Cursors{$$self}; my $txnId = $self->txn; $self->close; delete $Txns{$txnId}{Cursors}{$$self}; delete $Cursors{$$self}; } package LMDB_File; sub CLONE_SKIP { 1; } our $die_on_err = 1; our $last_err = 0; sub new { my($proto, $txn, $dbi) = @_; Carp::croak("Need a Txn") unless $txn->isa('LMDB::Txn'); bless [ $txn, $dbi ], ref($proto) || $proto; } sub open { my $proto = shift; my $class = ref $proto; my $txn = $class ? $proto->[0] : shift; Carp::croak("Need a Txn") unless $txn->isa('LMDB::Txn'); my $dbi = $txn->open(@_) or return; bless [ $txn, $dbi ], $class || $proto; } sub DESTROY { my $self = shift; } sub _chkalive { my $self = shift; my $txn = $self->[0]; Carp::croak("Not an active transaction") unless($txn && ($Txns{ $$txn } || undef $self->[0]) && $Txns{ $$txn }{Active} ); # A parent transaction and its cursors may not issue any other operations than # mdb_txn_commit and mdb_txn_abort while it has active child transactions. Carp::croak("Not the current child transaction") unless(${$Envs{ $txn->_env }[0][0]} == $$txn); $txn, $self->[1]; } sub Alive { my $self = shift; my $txn = $self->[0]; $txn && (($Txns{ $$txn } && $self->[1]) || undef $self->[0]); } sub flags { my $self = shift; _dbi_flags(_chkalive($self), my $flags); $flags; } sub put { my $self = shift; warn "put: '$_[0]' => '$_[1]'\n" if $DEBUG > 2; _put(_chkalive($self), @_); $_[1]; } sub get { warn "get: '$_[1]'\n" if $DEBUG > 2; my($txn, $dbi) = _chkalive($_[0]); return _get($txn, $dbi, $_[1], $_[2]) if @_ > 2; my($res, $data); { local $die_on_err = 0; $res = _get($txn, $dbi, $_[1], $data); } croak($@) if $res && $die_on_err && $res != MDB_NOTFOUND() or undef $@; $data; } sub Rget { warn "get: '$_[1]'\n" if $DEBUG > 2; local $die_on_err = 0; _get(_chkalive($_[0]), $_[1], my $data); return \$data; } sub del { _del(_chkalive($_[0]), $_[1], $_[2]); } sub stat { _stat(_chkalive($_[0])); } sub set_dupsort { my $self = shift; my $txn = $self->[0]; $Envs{ $txn->_env }[1][ $self->[1] ] = shift; } sub set_compare { my $self = shift; my $txn = $self->[0]; $Envs{ $txn->_env }[2][ $self->[1] ] = shift; } sub Cursor { my $DB = shift; my ($txn, $dbi) = _chkalive($DB); LMDB::Cursor::open($txn, $dbi, my $cursor); return unless $cursor; $Txns{$$txn}{Cursors}{$$cursor} = 1; $Cursors{$$cursor} = $DB; warn "Cursor opened for #$dbi\n" if $DEBUG; $cursor; } sub Txn : lvalue { $_[0][0]; } sub dbi : lvalue { $_[0][1]; } sub drop { _drop(_chkalive($_[0]), $_[1] || 0); } sub TIEHASH { my $proto = shift; return $proto if ref($proto) && _chkalive($proto); # Auto my $mux = shift; my $options = shift; $options = { flags => $options } unless ref $options; # DBM Compat my $txn; if(ref $mux eq 'LMDB::Txn') { $txn = $mux; } elsif(ref $mux eq 'LMDB::Env') { $txn = $mux->BeginTxn; $txn->AutoCommit(1); } else { # mux is dir $options->{mode} = shift if @_; # DBM Compat $txn = LMDB::Env->new($mux, $options)->BeginTxn; $txn->AutoCommit(1); } $txn->OpenDB($options); } sub FETCH { my($self, $key) = @_; my ($data, $res); { local $die_on_err = 0; $res = _get(_chkalive($self), $key, $data); } croak($@) if $res && $die_on_err && $res != MDB_NOTFOUND() or undef $@; $data; } *STORE = \&put; *CLEAR = \&drop; sub UNTIE { my $self = shift; my $txn = $self->[0]; return unless($txn && ($Txns{ $$txn } || undef($self->[0]))); delete $self->[2]; # Free cursor } sub SCALAR { return $_[0]->stat->{entries}; } sub EXISTS { my($self, $key) = @_; local $die_on_err = 0; return !_get(_chkalive($self), $key, my $dummy); } sub DELETE { my($self, $key) = @_; my @self = _chkalive($self); my $data; local $die_on_err = 0; if(_get(@self, $key, $data) != MDB_NOTFOUND()) { _del(@self, $key, undef); } return $data; } sub FIRSTKEY { my $self = shift; $self->[2] = $self->Cursor; $self->NEXTKEY; } # I hop some day tie hashed are optimized sub NEXTKEY { my($self, $key) = @_; my $op = defined($key) ? MDB_NEXT() : MDB_FIRST() ; local $die_on_err = 0; my $res = $self->[2]->get($key, my $data, $op); if($res == MDB_NOTFOUND()) { return; } return wantarray ? ($key, $data) : $key; } sub _mydbflags { my($envid, $dbi, $bit) = @_; my $cm = \vec($Envs{ $envid }[3], $dbi, LMDB_OFLAGN()); my $om = $$cm; if(@_ > 3) { $$cm = $_[3] ? ($$cm | $bit) : ($$cm & ~$bit); _resetcurdbi(); } return $om & $bit; } sub ReadMode { my $self = shift; my($txn, $dbi) = _chkalive($self); _mydbflags($txn->_env, $dbi, 1, @_); } sub UTF8 { my $self = shift; my($txn, $dbi) = _chkalive($self); _mydbflags($txn->_env, $dbi, 2, @_); } 1; __END__ =encoding utf-8 =head1 NAME LMDB_File - Tie to LMDB (OpenLDAP's Lightning Memory-Mapped Database) =head1 SYNOPSIS # Simple TIE interface, when you're in a rush use LMDB_File; $db = tie %hash, 'LMDB_File', $path; $hash{$key} = $value; $value = $hash{$key}; each %hash; keys %hash; values %hash; ... # The full power use LMDB_File qw(:flags :cursor_op); $env = LMDB::Env->new($path, { mapsize => 100 * 1024 * 1024 * 1024, # Plenty space, don't worry maxdbs => 20, # Some databases mode => 0600, # More options }); $txn = $env->BeginTxn(); # Open a new transaction $DB = $txn->OpenDB( { # Create a new database dbname => $dbname, flags => MDB_CREATE }); $DB->put($key, $value); # Simple put $value = $DB->get($key); # Simple get $DB->put($key, $value, MDB_NOOVERWITE); # Don't replace existing value # Work with cursors $cursor => $DB->Cursor; $cursor->get($key, $value, MDB_FIRST); # First key/value in DB $cursor->get($key, $value, MDB_NEXT); # Next key/value in DB $cursor->get($key, $value, MDB_LAST); # Last key/value in DB $cursor->get($key, $value, MDB_PREV); # Previous key/value in DB $DB->set_compare( sub { lc($a) cmp lc($b) } ); # Use my own key comparison function =head1 DESCRIPTION B B LMDB_File is a Perl module which allows Perl programs to make use of the facilities provided by OpenLDAP's Lightning Memory-Mapped Database "LMDB". LMDB is a Btree-based database management library modeled loosely on the BerkeleyDB API, but much simplified and extremely fast. It is assumed that you have a copy of LMBD's documentation at hand when reading this documentation. The interface defined here mirrors the C interface closely but with an OO approach. This is implemented with a number of Perl classes. A LMDB's B handler (MDB_env* in C) will be wrapped in the B class. A LMDB's B handler (MDB_txn* in C) will be wrapped in the B class. A LMDB's B handler (MDB_cursor* in C) will be wrapped in the B class. A LMDB's B handler (MDB_dbi in C) will be exposed as a simple integer, but because in LMDB all Database operations needs both a Transaction and a Database handler, LMDB_File provides you a convenient L object that encapsulates both and mimic the syntax of other *_File modules. =head1 Error reporting In the C API, most functions return 0 on success and an error code on failure. In this module, when a function fails, the package variable B<$die_on_err> controls the course of action. When B<$die_on_err> is set to TRUE, this causes LMDB_File to C with an error message that can be trapped by an C block. When FALSE, the function will return the error code, in this case you should check the return value of any function call. By default B<$die_on_err> is TRUE. Regardless of the value of B<$die_on_err>, the code of the last error can be found in the package variable B<$last_err>. =head1 LMDB::Env This class wraps an opened LMDB B. At construction time, the environment is created, if it does not exist, and opened. When you are finished using it, in the C API you must call the C function to close it and free the memory allocated, but in Perl you simply will let that the object get out of scope. =head2 Constructor $Env = LMDB::Env->new ( $path [, ENVOPTIONS ] ) Creates a new C object and returns it. It encapsulates both LMDB's C and C functions. I<$path> is the directory in which the database files reside. This directory must already exist and should be writable. B, if provided, must be a HASH Reference with any of the following options: =over =item mapsize => INT The size of the memory map to use for this environment. The size of the memory map is also the maximum size of the database. The value should be chosen as large as possible, to accommodate future growth of the database. The size should be a multiple of the OS page size. The default is 1048576 bytes (1 MB). =item maxreaders => INT The maximum number of threads/reader slots for the environment. This defines the number of slots in the lock table that is used to track readers in the environment. The default is 126. =item maxdbs => INT The maximum number of named databases for the environment. This option is only needed if multiple databases will be used in the environment. Simpler applications that use the environment as a single unnamed database can ignore this option. The default is 0, i.e. no named databases allowed. =item mode => INT The UNIX permissions to set on created files. This parameter is ignored on Windows. It defaults to 0600 =item flags => ENVFLAGS Set special options for this environment. This option, if provided, can be specified by OR'ing the following flags: =over =item MDB_FIXEDMAP Use a fixed address for the mmap region. This flag must be specified when creating the environment, and is stored persistently in the environment. If successful, the memory map will always reside at the same virtual address and pointers used to reference data items in the database will be constant across multiple invocations. This option may not always work, depending on how the operating system has allocated memory to shared libraries and other uses. The feature is highly experimental. =item MDB_NOSUBDIR By default, LMDB creates its environment in a directory whose pathname is given in I<$path>, and creates its data and lock files under that directory. With this option, I<$path> is used as-is for the database main data file. The database lock file is the I<$path> with "-lock" appended. =item MDB_RDONLY Open the environment in read-only mode. No write operations will be allowed. LMDB will still modify the lock file - except on read-only filesystems, where LMDB does not use locks. =item MDB_WRITEMAP Use a writeable memory map unless C is set. This is faster and uses fewer mallocs, but loses protection from application bugs like wild pointer writes and other bad updates into the database. Incompatible with nested transactions (also known as sub transactions). =item MDB_NOMETASYNC Flush system buffers to disk only once per transaction, omit the metadata flush. Defer that until the system flushes files to disk, or next non-MDB_RDONLY commit or C<< $Env->sync() >>. This optimization maintains database integrity, but a system crash may undo the last committed transaction. I.e. it preserves the ACI (atomicity, consistency, isolation) but not D (durability) database property. This flag may be changed at any time using C<< $Env->set_flags() >>. =item MDB_NOSYNC Don't flush system buffers to disk when committing a transaction. This optimization means a system crash can corrupt the database or lose the last transactions if buffers are not yet flushed to disk. The risk is governed by how often the system flushes dirty buffers to disk and how often C<< $Env->sync() >> is called. However, if the filesystem preserves write order and the C flag is not used, transactions exhibit ACI (atomicity, consistency, isolation) properties and only lose D (durability). I.e. database integrity is maintained, but a system crash may undo the final transactions. Note that C leaves the system with no hint for when to write transactions to disk, unless C<< $Env->sync() >> is called. C) may be preferable. This flag may be changed at any time using C<< $Env->set_flags() >>. =item MDB_MAPASYNC When using C, use asynchronous flushes to disk. As with C, a system crash can then corrupt the database or lose the last transactions. Calling C<< $Env->sync() >> ensures on-disk database integrity until next commit. This flag may be changed at any time using C<< $Env->set_flags() >>. =item MDB_NOTLS Don't use Thread-Local Storage. Tie reader locktable slots to L objects instead of to threads. I.e. C<< $Txn->reset() >> keeps the slot reserved for the L object. A thread may use parallel read-only transactions. A read-only transaction may span threads if the user synchronizes its use. Applications that multiplex many user threads over individual OS threads need this option. Such an application must also serialize the write transactions in an OS thread, since LMDB's write locking is unaware of the user threads. =back =back =head2 Class methods =over =item $Env->copy ( $path ) Copy an LMDB environment to the specified I<$path> =item $Env->copyfd ( HANDLE ) Copy an LMDB environment to the specified B. =item $status = $Env->stat Returns a HASH reference with statistics for the main, unnamed, database in the environment, the HASH contains the following keys: =over =item B Size of a database page. =item B Depth (height) of the B-Tree =item B Number of internal (non-leaf) pages =item B Number of overflow pages =item B Number of data items =back =item $info = $Env->info Returns a HASH reference with information about the environment, I<$info>, with the following keys: =over =item B Address of map, if fixed =item B Size of the data memory map =item B ID of the last used page =item B ID of the last committed transaction =item B Max reader slots in the environment =item B Max reader slot used in the environment =back =item $Env->sync ( BOOL ) Flush the data buffers to disk. Data is always written to disk when C<< $Txn->commit() >> is called, but the operating system may keep it buffered. LMDB always flushes the OS buffers upon commit as well, unless the environment was opened with C or in part C. If I is TRUE force a synchronous flush. Otherwise if the environment has the C flag set the flushes will be omitted, and with C they will be asynchronous. =item $Env->set_flags ( BITMASK, BOOL ) As noted above, some environment flags can be changed at any time. I is the flags to change, bitwise OR'ed together. I TRUE set the flags, FALSE clears them. =item $Env->get_flags ( $flags ) Returns in I<$flags> the environment flags. =item $Env->get_path ( $path ) Returns in I<$path> the path that was used in C<< LMDB::Env->new(...) >> =item $Env->get_maxreaders ( $readers ) Returns in I<$readers> the maximum number of threads/reader slots for the environment =item $mks = $Env->get_maxkeysize Returns the maximum size of a key for the environment. =item $Txn = $Env->BeginTxn ( [ $tflags ] ) Returns a new Transaction. A simple wrapper over the constructor of L. If provided, $tflags will be passed to the constructor, if not provided, this wrapper will propagate the environment's flag C, if set, to the transaction constructor. =back =head1 LMDB::Txn In LMDB every operation (read or write) on a Database needs to be inside a B. This class wraps an LMDB transaction. You must terminate the transaction by either the C or C methods. After a transaction is terminated, you should not call any other method on it, except C. If you let an object of this class get out of scope, by default the transaction will be aborted. =head2 Constructor $Txn = LMDB::Txn->new ( $Env [, $tflags ] ) Create a new B for use in the B. =head2 Class methods =over =item $Txn->abort Abort the transaction, terminating the transaction. =item $Txn->commit Commit the transaction, terminating the transaction. =item $Txn->reset Reset a read-only transaction. Abort the transaction like C<< $Txn->abort() >>, but keep the transaction handle in the inactive state so C<< $Txn->renew() >> may reactivate the handle. This saves allocation overhead if the process will start a new read-only transaction soon, and also saves locking overhead if MDB_NOTLS is in use. The reader table lock is released, but the table slot stays tied to its thread or Transaction. Use C<< $Txn->abort() >> to discard a reseted handle, and to free its lock table slot if MDB_NOTLS is in use. =item $Txn->renew Renew a read-only transaction. This acquires a new reader lock for a transaction handle that had been inactivated by C<< $Txn->reset() >>. It must be called before an inactive (reseted) transaction may be used again. In this Perl implementation if you call C<< $Txn->renew() >> in an active Transaction the method internally calls C<< $Txn->reset() >> for you. =item $Env = $Txn->env Returns the environment (an LMDB::Env object) that created the transaction, if it is still alive, or C if called on a terminated transaction. =item $SubTxn = $Txn->SubTxn ( [ $tflags ] ) Creates and returns a sub transaction (also known as a nested transaction). Nested transactions are useful for combining components that create and commit transactions. No modifications are permanently stored until the highest level "parent" transaction is committed. Nested transactions can be aborted without aborting the parent transaction and only the changes made in the nested transaction will be rolled-back. Aborting the parent transaction will abort and terminate all outstanding nested transactions. Committing the parent transaction will similarly commit and terminate all outstanding nested transactions. Unlike some other databases, in LMDB changes made inside nested transactions are not visible to the parent transaction until the nested transaction is committed. In other words, transactions are always isolated, even when they are nested. =item $Txn->AutoCommit ( [ BOOL ] ) When I is provided, it sets the behavior of the transaction when going out of scope: I TRUE makes arrangements for the transaction to be auto committed and I FALSE returns to the default behavior: to be aborted. If you don't provide I, you are only interested in knowing the current value of this option, which is returned in every case. =item $DB = $Txn->OpenDB ( [ DBOPTIONS ] ) =item $DB = $Txn->OpenDB ( [ $dbname [, DBFLAGS ]] ) This method opens a Database in the environment and returns a L object that encapsulates both the Transaction and the Database handler. This is a convenience shortcut for C<< LMDB_File->new( $Txn, $Txn->open(...) ) >> for use when you want to use the hi-level LMDB_File's OO approach. B, if provided, should be a HASH reference with any of the following keys: =over =item B => $dbname =item B => DBFLAGS =back You can also call this method using its values, I<$dbname> and B, documented ahead. =item $dbi = $Txn->open ( [ $dbname [, DBFLAGS ]] ) This method open a Database in the environment and returns the low level Database handler, an integer. If provided I<$dbname>, will be the name of a named Database in the environment, if not provided (or if I<$dbname> is C), the opened Database will be the unnamed (the default) one. B, if provided, will set special options for this Database and can be specified by OR'ing the following flags: =over =item MDB_REVERSEKEY Keys are strings to be compared in reverse order =item MDB_DUPSORT Duplicate keys may be used in the database. (Or, from another perspective, keys may have multiple data items, stored in sorted order.) By default keys must be unique and may have only a single data item. =item MDB_INTEGERKEY Keys are binary integers in native byte order. =item MDB_DUPFIXED This flag may only be used in combination with #MDB_DUPSORT. This option tells the library that the data items for this database are all the same size, which allows further optimizations in storage and retrieval. When all data items are the same size, the #MDB_GET_MULTIPLE and #MDB_NEXT_MULTIPLE cursor operations may be used to retrieve multiple items at once. =item MDB_INTEGERDUP This option specifies that duplicate data items are also integers, and should be sorted as such. =item MDB_REVERSEDUP This option specifies that duplicate data items should be compared as strings in reverse order. =item MDB_CREATE Create the named database if it doesn't exist. This option is not allowed in a read-only transaction or a read-only environment. After successfully commit the transaction that created the Database, it will remains opened in the Environment so you can reuse I<$dbi> in other transactions. =back If you will need to use that Database handler in more than one transaction or want to use a more traditional (in LMDB's point of view) approach, this the method you should use. To operate in the opened database with the returned I<$dbi> handler you can use the methods described bellow or call C<< LMDB_File->new(...) >> to obtain a L object to operate the database in a particular transaction. =item $Txn->put ( $dbi, $key, $data [, WRITEFLAGS [, $length ] ) Store items into the database I<$dbi> Provided for when your main concern is the raw speed. For details of the other arguments, please see the method of the same name in LMDB_File below. =item $Txn->get ( $dbi, $key, $data ) Get items from the database I<$dbi> Provided for when your main concern is the raw speed. For details of the other arguments, please see the method of the same name in LMDB_File below. =item $Txn->id () Return the transaction's ID. This returns the identifier associated with this transaction. For a read-only transaction, this corresponds to the snapshot being read; concurrent readers will frequently have the same transaction ID. =back =head1 LMDB_File In the LMDB C API all Database operations need both an active Transaction and a Database handler. To simplify those operations and be syntax compatible with others *_File modules, this Perl API provides you a B object that encapsulates both and implements some hi-level extensions. LMDB_File's methods, in contrast to the LMDB::Txn's ones of the same name, perform some checks before calling the low-level C API. =head2 Constructors =over =item $DB = LMDB_File->new( $Txn, $dbi ) Associates a Transaction I<$Txn> with a previously opened Database handler I<$dbi> to use this OO API =item $DB = LMDB_File->open ( $Txn [, $dbname [, DBFLAGS ] ] ) An alternative to C<< $Txn->OpenDB(...) >> for open a Database and associate it with a Transaction in one call. =back =head2 Class methods =over =item $DB->put ( $key, $data [, WRITEFLAGS [, $length ] ] ) Store items into a database. This function stores key/data pairs in the database. The default behavior is to enter the new key/data pair, replacing any previously existing key if duplicates are disallowed, or adding a duplicate data item if duplicates are allowed I<$key> is the key to store in the database and I<$data> the data to store. B, if provided, will set special options for this operation and can be one of following flags: =over =item MDB_NODUPDATA Enter the new key/data pair only if it does not already appear in the database. This flag may only be specified if the database was opened with #MDB_DUPSORT. The function will fail with MDB_KEYEXIST if the key/data pair already appears in the database. =item MDB_NOOVERWRITE Enter the new key/data pair only if the key does not already appear in the database. The function will return MDB_KEYEXIST if the key already appears in the database, even if the database supports duplicates (#MDB_DUPSORT). The I<$data> parameter will be set to the existing item. =item MDB_RESERVE Reserve space for data of the given size in I<$length>, but don't copy anything. Instead, return in I<$data> a magical scalar with a pointer to the reserved space, which the caller can fill in later, but before the next update operation or the transaction ends. This saves an extra memcpy if the data is being generated later. In this particular case, you need to pass the extra I<$length> parameter to specify how many bytes to reserve. Please read about the C<< $DB->ReadMode >> method caveats bellow for details that apply to the magical scalar returned in I<$data> in this case. =item MDB_APPEND Append the given key/data pair to the end of the database. No key comparisons are performed. This option allows fast bulk loading when keys are already known to be in the correct order. B Loading unsorted keys with this flag will cause data corruption. =item MDB_APPENDDUP As above, but for sorted duplicated data. =back =item $DB->get ( $key, $data ) =item $data = $DB->get ( $key ) Get items from a database. This method retrieves key/data pairs from the database. If the database supports duplicate keys (#MDB_DUPSORT) then the first data item for the key will be returned. Retrieval of other items requires the use of the C<< LMBD::Cursor->get() >> method. The two-argument form, closer to the C API, returns in the provided argument I<$data> the value associated with I<$key> in the database if it exists or reports an error if not. In the simpler, more "perlish" one-argument form, the method returns the value associated with I<$key> in the database or C if no such value exists. =item $DB->del ( $key [, $data ] ) Delete items from the database. This function removes key/data pairs from the database. If the database does not support sorted duplicate data items, (MDB_DUPSORT) the I<$data> parameter is optional and is ignored. If the database supports sorted duplicates and the I<$data> parameter is C or not provided, all of the duplicate data items for the I<$key> will be deleted. Otherwise, if the I<$data> parameter is provided only the matching data item will be deleted. =item $DB->set_compare ( CODE ) Set a custom key comparison function referenced by I for a database. I should be a subroutine reference or an anonymous subroutine, that like Perl's L, will receive the values to compare in the global variables C<$a> and C<$b>. The comparison function is called whenever it is necessary to compare a key specified by the application with a key currently stored in the database. If no comparison function is specified, and no special key flags were specified in C<< LMDB_File->open() >>, the keys are compared lexically, with shorter keys collating before longer keys. B This function must be called before any data access functions are used, otherwise data corruption may occur. The same comparison function must be used by every program accessing the database, every time the database is used. =item $flags = $DB->flags Retrieve the DB flags for the associated database. =item $status = $DB->stat Returns a HASH reference with statistics for the associated database, the hash will contain the following keys: =over =item B Size of a database page. =item B Depth (height) of the B-Tree =item B Number of internal (non-leaf) pages =item B Number of overflow pages =item B Number of data items =back =item $DB->drop( [ REMOVE ] ) If I isn't provided or FALSE, the database is emptied. If I is TRUE the database is closed and removed from the Environment. =item $DB->Alive Returns a TRUE value if the associated transaction is still alive, i.e. not commited nor aborted yet, and FALSE otherwise. =item $Cursor = $DB->Cursor Creates a new LMDB::Cursor object to work in the database, see L =item $txn = $DB->Txn Returns the transaction, an L object, associated with I<$DB>. $DB->Txn->commit; # Commit the current transaction. If the method C<< $DB->Alive >> has returned FALSE before, this method will return C. You can use C<< $DB->Txn >> as an lvalue to change the associated Transaction, but remember that, if C<$DB> is holding the last reference of the current transaction, that transaction will be terminated. $DB->Txn->commit; # Commit current $DB->Alive; # FALSE ... $DB->Txn = $Env->BeginTxn; # Start another, with same Database ... =item $dbi = $DB->dbi Returns the low level Database handler associated with I<$DB> You can use C<< $DB->dbi >> as an lvalue to switch the associated Datbase hander: $DB->dbi = $other_dbi; =item $DB->ReadMode ( [ MODE ] ) This method allows you to modify the behavior of "get" (read) operations on the database. The C documentation for the C function states that: The memory pointed to by the returned values is owned by the database. The caller need not dispose of the memory, and may not modify it in any way. For values returned in a read-only transaction any modification attempts will cause a SIGSEGV. So this module implements two modes of operation for its "get" methods and you can select between them with this method. When MODE is 0 (or any FALSE value) a default "safe" mode is used in which the data value found in the database is copied to the scalar returned, so you can do anything you want to that scalar without side effects. But when MODE is 1 (or, in the current implementation, any TRUE value) a sort of hack is used to avoid the memory copy and a magical scalar returned that hold only a pointer to the data value found. This is much faster and uses less memory, especially when used with large values. In a environment opened with MDB_WRITEMAP and in a transaction without the MDB_RDONLY flag, you are allowed to modify the returned scalar, and the modifications are reflected to the associated memory block and preserved in the database when the transaction is commited. Otherwise the magical scalar is marked READ-ONLY and any attempt to modify it (other than reuse it in another C<< $DB->get >> ), will cause perl to croak. B In a read-only transaction the value is valid only until the end of the transaction, and in a read-write transaction the value is valid only until the next write operation (because any write operation can potentially modify the in-memory btree). In the current implementation, you are responsible for the proper timing of usage. B In order to achieve the zero-copy behavior desired by setting L to TRUE, you must use the two-argument form of get (C<< $DB->get ( $key, $data ) >>), use the new C<< $DB->Rget( $key ) >> or use the cursor get method described below. =item $DB->UTF8 ( [ MODE ] ) Instructs LDMB_File to use the UTF-8 encoding for the associated database when I is 1 or revert to raw bytes when 0. Returns the previous value. By default, all values in LMDB are simple byte buffers of certain fixed length. So if you are storing binary data in your database all works as expected: what you put is what you get. But when you need to store some arbitrary Unicode text value, remember that internally perl stores your strings in either the native eight-bit character set or in UTF-8, and to warrant a consistent encoding in your database you should do something like: use Encoding; ... $DB->put($key, Encode::encode($my_encoding, $characters)); $characters = Encode::decode($my_encoding, $DB->get($key)); For any value of $my_encoding, see L for the gory details. But if you use for interchange the UTF-8 encoding, with this method you can avoid all that typing. When I is 1, all values that you put in the Database will be encoded in UTF-8, And all get calls will expect UTF-8 data and it will be verified and decoded. In this mode, if malformed data is found, a warning will be emitted, the decode attempt aborted and the raw bytes returned. In this mode, a C<< $foo->get(...) >> call interacts with the L pragma in a special way: In the lexical scope under the effects of C, any get call skips the decode step, returning the fetched encoded UTF-8 data as bytes, i.e. with the internal perl UTF8 flag off, as expected by modules like JSON::XS. =back =head1 LMDB::Cursor To construct a cursor you should call the C method of the C class: $cursor = $DB->Cursor =head2 Class methods =over =item $cursor->get($key, $data, CURSOR_OP) This function retrieves key/data pairs from the database. The variables I<$key> and I<$data> are used to return the values found. B determines the key/data to be retrieved and must be one of the following: =over =item MDB_FIRST Position at first key/data item. =item MDB_FIRST_DUP Position at first data item of current key. Only for C =item MDB_GET_BOTH Position at key/data pair. Only for C =item MDB_GET_BOTH_RANGE Position at key, nearest data. Only for C =item MDB_GET_CURRENT Return key/data at current cursor position. =item MDB_GET_MULTIPLE Return all the duplicate data items at the current cursor position. Only for C =item MDB_LAST Position at last key/data item. =item MDB_LAST_DUP Position at last data item of current key. Only for C =item MDB_NEXT Position at next data item. =item MDB_NEXT_DUP Position at next data item of current key. Only for C =item MDB_NEXT_MULTIPLE Return all duplicate data items at the next cursor position. Only for C =item MDB_NEXT_NODUP Position at first data item of next key. =item MDB_PREV Position at previous data item. =item MDB_PREV_DUP Position at previous data item of current key. Only for C =item MDB_PREV_NODUP Position at last data item of previous key. =item MDB_SET Position at specified key. =item MDB_SET_KEY Position at specified key, return key + data. =item MDB_SET_RANGE Position at first key greater than or equal to specified key. =back =item $cursor->put($key, $data, WRITEFLAGS) This function stores key/data pairs into the database. If the function succeeds and an item is inserted into the database, the cursor is always positioned to refer to the newly inserted item. If the function fails for any reason, the state of the cursor will undetermined. B Earlier documentation incorrectly said errors would leave the state of the cursor unchanged. =item $cursor->del( [ DELFLAGS ] ) This function deletes the key/data pair to which the cursor refers. If the database was opened with C, the optional parameter I can be C to deletes all of the data items for the current key. =back =head1 Exportable constants At C time you can import into your namespace the following constants, grouped by their tags. =head2 Environment flags C<:envflags> MDB_FIXEDMAP MDB_NOSUBDIR MDB_NOSYNC MDB_RDONLY MDB_NOMETASYNC MDB_WRITEMAP MDB_MAPASYNC MDB_NOTLS =head2 Data base flags C<:dbflags> MDB_REVERSEKEY MDB_DUPSORT MDB_INTEGERKEY MDB_DUPFIXED MDB_INTEGERDUP MDB_REVERSEDUP MDB_CREATE =head2 Write flags C<:writeflags> MDB_NOOVERWRITE MDB_NODUPDATA MDB_CURRENT MDB_RESERVE MDB_APPEND MDB_APPENDDUP MDB_MULTIPLE =head2 All flags C<:flags> All of C<:envflags>, C<:dbflags> and C<:writeflags> =head2 Cursor operations C<:cursor_op> MDB_FIRST MDB_FIRST_DUP MDB_GET_BOTH MDB_GET_BOTH_RANGE MDB_GET_CURRENT MDB_GET_MULTIPLE MDB_NEXT MDB_NEXT_DUP MDB_NEXT_MULTIPLE MDB_NEXT_NODUP MDB_PREV MDB_PREV_DUP MDB_PREV_NODUP MDB_LAST MDB_LAST_DUP MDB_SET MDB_SET_KEY MDB_SET_RANGE =head2 Error codes C<:error> MDB_SUCCESS MDB_KEYEXIST MDB_NOTFOUND MDB_PAGE_NOTFOUND MDB_CORRUPTED MDB_PANIC MDB_VERSION_MISMATCH MDB_INVALID MDB_MAP_FULL MDB_DBS_FULL MDB_READERS_FULL MDB_TLS_FULL MDB_TXN_FULL MDB_CURSOR_FULL MDB_PAGE_FULL MDB_MAP_RESIZED MDB_INCOMPATIBLE MDB_BAD_RSLOT MDB_LAST_ERRCODE =head2 Version information C<:version> MDB_VERSION_FULL MDB_VERSION_MAJOR MDB_VERSION_MINOR MDB_VERSION_PATCH MDB_VERSION_STRING MDB_VERSION_DATE =head1 TIE Interface The simplest interface to LMDB is using L. The TIE interface of LMDB_File can take several forms that depend on the data at hand. =over =item tie %hash, 'LMDB_File', $path [, $options ] The most simple form. =item tie %hash, 'LMDB_File', $path, $flags, $mode For compatibility with other DBM modules. =item tie %hash, 'LMDB_File', $Txn [, DBOPTIONS ] When you have a Transaction object I<$Txn> at hand. =item tie %hash, 'LMDB_File', $Env [, DBOPTIONS ] When you have an Environment object I<$Env> at hand. =item tie %hash, $DB When you have an opened Transaction encapsulated database. =back The first two forms will create and/or open the Environment at I<$path>, create a new Transaction and open a Database in the Transaction. If provided, I<$options> must be a HASH reference with options for both the Environment and the database. Valid keys for I<$option> are any described above for B and B. In the case that you have already created a transaction or an environment, you can provide a HASH reference in B for options exclusively for the database. In the forms that needs to create a Transaction, this is setted for B mode. =head1 AUTHOR Salvador Ortiz Garcia, Esortiz@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013-2021 by Salvador Ortiz García Copyright (C) 2013-2021 by Matías Software Group, S.A. de C.V. This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License version 2.0, see L. =cut LMDB_File-0.13/META.json0000644000175600003110000000241214552575256013075 0ustar sogsoft{ "abstract" : "Tie to LMDB (OpenLDAP's Lightning Memory-Mapped Database)", "author" : [ "Salvador Ortiz " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010", "license" : [ "artistic_2" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "LMDB_File", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.64" } }, "runtime" : { "requires" : { "perl" : "5.010000" } }, "test" : { "requires" : { "Test::Exception" : "0", "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "repository" : { "type" : "git", "url" : "git://github.com/salortiz/LMDB_File.git", "web" : "https://github.com/salortiz/LMDB_File" } }, "version" : "0.13", "x_serialization_backend" : "JSON::PP version 4.16" } LMDB_File-0.13/ppport.h0000644000175600003110000054004412422257127013145 0ustar sogsoft#if 0 <<'SKIP'; #endif /* ---------------------------------------------------------------------- ppport.h -- Perl/Pollution/Portability Version 3.20 Automatically created by Devel::PPPort running under perl 5.016003. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. Use 'perldoc ppport.h' to view the documentation below. ---------------------------------------------------------------------- SKIP =pod =head1 NAME ppport.h - Perl/Pollution/Portability version 3.20 =head1 SYNOPSIS perl ppport.h [options] [source files] Searches current directory for files if no [source files] are given --help show short help --version show version --patch=file write one patch file with changes --copy=suffix write changed copies with suffix --diff=program use diff program and options --compat-version=version provide compatibility with Perl version --cplusplus accept C++ comments --quiet don't output anything except fatal errors --nodiag don't show diagnostics --nohints don't show hints --nochanges don't suggest changes --nofilter don't filter input files --strip strip all script and doc functionality from ppport.h --list-provided list provided API --list-unsupported list unsupported API --api-info=name show Perl API portability information =head1 COMPATIBILITY This version of F is designed to support operation with Perl installations back to 5.003, and has been tested up to 5.11.5. =head1 OPTIONS =head2 --help Display a brief usage summary. =head2 --version Display the version of F. =head2 --patch=I If this option is given, a single patch file will be created if any changes are suggested. This requires a working diff program to be installed on your system. =head2 --copy=I If this option is given, a copy of each file will be saved with the given suffix that contains the suggested changes. This does not require any external programs. Note that this does not automagially add a dot between the original filename and the suffix. If you want the dot, you have to include it in the option argument. If neither C<--patch> or C<--copy> are given, the default is to simply print the diffs for each file. This requires either C or a C program to be installed. =head2 --diff=I Manually set the diff program and options to use. The default is to use C, when installed, and output unified context diffs. =head2 --compat-version=I Tell F to check for compatibility with the given Perl version. The default is to check for compatibility with Perl version 5.003. You can use this option to reduce the output of F if you intend to be backward compatible only down to a certain Perl version. =head2 --cplusplus Usually, F will detect C++ style comments and replace them with C style comments for portability reasons. Using this option instructs F to leave C++ comments untouched. =head2 --quiet Be quiet. Don't print anything except fatal errors. =head2 --nodiag Don't output any diagnostic messages. Only portability alerts will be printed. =head2 --nohints Don't output any hints. Hints often contain useful portability notes. Warnings will still be displayed. =head2 --nochanges Don't suggest any changes. Only give diagnostic output and hints unless these are also deactivated. =head2 --nofilter Don't filter the list of input files. By default, files not looking like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped. =head2 --strip Strip all script and documentation functionality from F. This reduces the size of F dramatically and may be useful if you want to include F in smaller modules without increasing their distribution size too much. The stripped F will have a C<--unstrip> option that allows you to undo the stripping, but only if an appropriate C module is installed. =head2 --list-provided Lists the API elements for which compatibility is provided by F. Also lists if it must be explicitly requested, if it has dependencies, and if there are hints or warnings for it. =head2 --list-unsupported Lists the API elements that are known not to be supported by F and below which version of Perl they probably won't be available or work. =head2 --api-info=I Show portability information for API elements matching I. If I is surrounded by slashes, it is interpreted as a regular expression. =head1 DESCRIPTION In order for a Perl extension (XS) module to be as portable as possible across differing versions of Perl itself, certain steps need to be taken. =over 4 =item * Including this header is the first major one. This alone will give you 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 prefix is deprecated. Also, some API functions used to have a C prefix. Using this form is also deprecated. You can safely use the supported API, as F 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. These functions or variables will be marked C 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 or global variants. For a C 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 grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL load_module() NEED_load_module NEED_load_module_GLOBAL my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL my_sprintf() NEED_my_sprintf NEED_my_sprintf_GLOBAL my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL newSV_type() NEED_newSV_type NEED_newSV_type_GLOBAL newSVpvn_flags() NEED_newSVpvn_flags NEED_newSVpvn_flags_GLOBAL newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL pv_display() NEED_pv_display NEED_pv_display_GLOBAL pv_escape() NEED_pv_escape NEED_pv_escape_GLOBAL pv_pretty() NEED_pv_pretty NEED_pv_pretty_GLOBAL sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL vload_module() NEED_vload_module NEED_vload_module_GLOBAL vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL warner() NEED_warner NEED_warner_GLOBAL To avoid namespace conflicts, you can change the namespace of the explicitly exported functions / variables using the C macro. Just C<#define> the macro before including C: #define DPPP_NAMESPACE MyOwnNamespace_ #include "ppport.h" The default namespace is C. =back The good thing is that most of the above can be checked by running F on your source code. See the next section for details. =head1 EXAMPLES To verify whether F is needed for your module, whether you should make any changes to your code, and whether any special defines should be used, F can be run as a Perl script to check your source code. Simply say: perl ppport.h The result will usually be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. If you know that your XS module uses features only available in newer Perl releases, if you're aware that it uses C++ comments, and if you want all suggestions as a single patch file, you could use something like this: perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff If you only want your code to be scanned without any suggestions for changes, use: perl ppport.h --nochanges You can specify a different C program or options, using the C<--diff> option: perl ppport.h --diff='diff -C 10' This would output context diffs with 10 lines of context. If you want to create patched copies of your files instead, use: perl ppport.h --copy=.new To display portability information for the C function, use: perl ppport.h --api-info=newSVpvn Since the argument to C<--api-info> can be a regular expression, you can use perl ppport.h --api-info=/_nomg$/ to display portability information for all C<_nomg> functions or perl ppport.h --api-info=/./ to display information for all known API elements. =head1 BUGS If this version of F is causing failure during the compilation of this module, please check if newer versions of either this module or C are available on CPAN before sending a bug report. If F was generated using the latest version of C and is causing failure of this module, please file a bug report using the CPAN Request Tracker at L. Please include the following information: =over 4 =item 1. The complete output from running "perl -V" =item 2. This file. =item 3. The name and version of the module you were trying to build. =item 4. A full log of the build that failed. =item 5. Any other information that you think could be relevant. =back For the latest version of this code, please get the C module from CPAN. =head1 COPYRIGHT Version 3.x, Copyright (c) 2004-2010, Marcus Holland-Moritz. Version 2.x, Copyright (C) 2001, Paul Marquess. Version 1.x, Copyright (C) 1999, Kenneth Albanowski. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO See L. =cut use strict; # Disable broken TRIE-optimization BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 } my $VERSION = 3.20; my %opt = ( quiet => 0, diag => 1, hints => 1, changes => 1, cplusplus => 0, filter => 1, strip => 0, version => 0, ); my($ppport) = $0 =~ /([\w.]+)$/; my $LF = '(?:\r\n|[\r\n])'; # line feed my $HS = "[ \t]"; # horizontal whitespace # Never use C comments in this file! my $ccs = '/'.'*'; my $cce = '*'.'/'; my $rccs = quotemeta $ccs; my $rcce = quotemeta $cce; eval { require Getopt::Long; Getopt::Long::GetOptions(\%opt, qw( help quiet diag! filter! hints! changes! cplusplus strip version patch=s copy=s diff=s compat-version=s list-provided list-unsupported api-info=s )) or usage(); }; if ($@ and grep /^-/, @ARGV) { usage() if "@ARGV" =~ /^--?h(?:elp)?$/; die "Getopt::Long not found. Please don't use any options.\n"; } if ($opt{version}) { print "This is $0 $VERSION.\n"; exit 0; } usage() if $opt{help}; strip() if $opt{strip}; if (exists $opt{'compat-version'}) { my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) }; if ($@) { die "Invalid version number format: '$opt{'compat-version'}'\n"; } die "Only Perl 5 is supported\n" if $r != 5; die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000; $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s; } else { $opt{'compat-version'} = 5; } my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/ ? ( $1 => { ($2 ? ( base => $2 ) : ()), ($3 ? ( todo => $3 ) : ()), (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()), (index($4, 'p') >= 0 ? ( provided => 1 ) : ()), (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()), } ) : die "invalid spec: $_" } qw( AvFILLp|5.004050||p AvFILL||| BhkDISABLE||5.014000| BhkENABLE||5.014000| BhkENTRY_set||5.014000| BhkENTRY||| BhkFLAGS||| CALL_BLOCK_HOOKS||| CLASS|||n CPERLscope|5.005000||p CX_CURPAD_SAVE||| CX_CURPAD_SV||| CopFILEAV|5.006000||p CopFILEGV_set|5.006000||p CopFILEGV|5.006000||p CopFILESV|5.006000||p CopFILE_set|5.006000||p CopFILE|5.006000||p CopSTASHPV_set|5.006000||p CopSTASHPV|5.006000||p CopSTASH_eq|5.006000||p CopSTASH_set|5.006000||p CopSTASH|5.006000||p CopyD|5.009002||p Copy||| CvPADLIST||| CvSTASH||| CvWEAKOUTSIDE||| DEFSV_set|5.010001||p DEFSV|5.004050||p END_EXTERN_C|5.005000||p ENTER||| ERRSV|5.004050||p EXTEND||| EXTERN_C|5.005000||p F0convert|||n FREETMPS||| GIMME_V||5.004000|n GIMME|||n GROK_NUMERIC_RADIX|5.007002||p G_ARRAY||| G_DISCARD||| G_EVAL||| G_METHOD|5.006001||p G_NOARGS||| G_SCALAR||| G_VOID||5.004000| GetVars||| GvSVn|5.009003||p GvSV||| Gv_AMupdate||5.011000| HEf_SVKEY||5.004000| HeHASH||5.004000| HeKEY||5.004000| HeKLEN||5.004000| HePV||5.004000| HeSVKEY_force||5.004000| HeSVKEY_set||5.004000| HeSVKEY||5.004000| HeUTF8||5.010001| HeVAL||5.004000| HvENAME||5.013007| HvNAMELEN_get|5.009003||p HvNAME_get|5.009003||p HvNAME||| INT2PTR|5.006000||p IN_LOCALE_COMPILETIME|5.007002||p IN_LOCALE_RUNTIME|5.007002||p IN_LOCALE|5.007002||p IN_PERL_COMPILETIME|5.008001||p IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p IS_NUMBER_INFINITY|5.007002||p IS_NUMBER_IN_UV|5.007002||p IS_NUMBER_NAN|5.007003||p IS_NUMBER_NEG|5.007002||p IS_NUMBER_NOT_INT|5.007002||p IVSIZE|5.006000||p IVTYPE|5.006000||p IVdf|5.006000||p LEAVE||| LINKLIST||5.013006| LVRET||| MARK||| MULTICALL||5.014000| MY_CXT_CLONE|5.009002||p MY_CXT_INIT|5.007003||p MY_CXT|5.007003||p MoveD|5.009002||p Move||| NOOP|5.005000||p NUM2PTR|5.006000||p NVTYPE|5.006000||p NVef|5.006001||p NVff|5.006001||p NVgf|5.006001||p Newxc|5.009003||p Newxz|5.009003||p Newx|5.009003||p Nullav||| Nullch||| Nullcv||| Nullhv||| Nullsv||| OP_CLASS||5.013007| OP_DESC||5.007003| OP_NAME||5.007003| ORIGMARK||| PAD_BASE_SV||| PAD_CLONE_VARS||| PAD_COMPNAME_FLAGS||| PAD_COMPNAME_GEN_set||| PAD_COMPNAME_GEN||| PAD_COMPNAME_OURSTASH||| PAD_COMPNAME_PV||| PAD_COMPNAME_TYPE||| PAD_DUP||| PAD_RESTORE_LOCAL||| PAD_SAVE_LOCAL||| PAD_SAVE_SETNULLPAD||| PAD_SETSV||| PAD_SET_CUR_NOSAVE||| PAD_SET_CUR||| PAD_SVl||| PAD_SV||| PERLIO_FUNCS_CAST|5.009003||p PERLIO_FUNCS_DECL|5.009003||p PERL_ABS|5.008001||p PERL_BCDVERSION|5.014000||p PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p PERL_HASH|5.004000||p PERL_INT_MAX|5.004000||p PERL_INT_MIN|5.004000||p PERL_LONG_MAX|5.004000||p PERL_LONG_MIN|5.004000||p PERL_MAGIC_arylen|5.007002||p 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.014000||p PERL_MAGIC_isaelem|5.007002||p PERL_MAGIC_isa|5.007002||p PERL_MAGIC_mutex|5.014000||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 PERL_MAGIC_utf8|5.008001||p PERL_MAGIC_uvar_elem|5.007003||p PERL_MAGIC_uvar|5.007002||p PERL_MAGIC_vec|5.007002||p PERL_MAGIC_vstring|5.008001||p PERL_PV_ESCAPE_ALL|5.009004||p PERL_PV_ESCAPE_FIRSTCHAR|5.009004||p PERL_PV_ESCAPE_NOBACKSLASH|5.009004||p PERL_PV_ESCAPE_NOCLEAR|5.009004||p PERL_PV_ESCAPE_QUOTE|5.009004||p PERL_PV_ESCAPE_RE|5.009005||p PERL_PV_ESCAPE_UNI_DETECT|5.009004||p PERL_PV_ESCAPE_UNI|5.009004||p PERL_PV_PRETTY_DUMP|5.009004||p PERL_PV_PRETTY_ELLIPSES|5.010000||p PERL_PV_PRETTY_LTGT|5.009004||p PERL_PV_PRETTY_NOCLEAR|5.010000||p PERL_PV_PRETTY_QUOTE|5.009004||p PERL_PV_PRETTY_REGPROP|5.009004||p PERL_QUAD_MAX|5.004000||p PERL_QUAD_MIN|5.004000||p PERL_REVISION|5.006000||p PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p PERL_SCAN_DISALLOW_PREFIX|5.007003||p PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p PERL_SCAN_SILENT_ILLDIGIT|5.008001||p PERL_SHORT_MAX|5.004000||p PERL_SHORT_MIN|5.004000||p PERL_SIGNALS_UNSAFE_FLAG|5.008001||p PERL_SUBVERSION|5.006000||p PERL_SYS_INIT3||5.006000| PERL_SYS_INIT||| PERL_SYS_TERM||5.014000| PERL_UCHAR_MAX|5.004000||p PERL_UCHAR_MIN|5.004000||p PERL_UINT_MAX|5.004000||p PERL_UINT_MIN|5.004000||p PERL_ULONG_MAX|5.004000||p PERL_ULONG_MIN|5.004000||p PERL_UNUSED_ARG|5.009003||p PERL_UNUSED_CONTEXT|5.009004||p PERL_UNUSED_DECL|5.007002||p PERL_UNUSED_VAR|5.007002||p PERL_UQUAD_MAX|5.004000||p PERL_UQUAD_MIN|5.004000||p PERL_USE_GCC_BRACE_GROUPS|5.009004||p PERL_USHORT_MAX|5.004000||p PERL_USHORT_MIN|5.004000||p PERL_VERSION|5.006000||p PL_DBsignal|5.005000||p PL_DBsingle|||pn PL_DBsub|||pn PL_DBtrace|||pn PL_Sv|5.005000||p PL_bufend|5.014000||p PL_bufptr|5.014000||p PL_compiling|5.004050||p PL_copline|5.014000||p PL_curcop|5.004050||p PL_curstash|5.004050||p PL_debstash|5.004050||p PL_defgv|5.004050||p PL_diehook|5.004050||p PL_dirty|5.004050||p PL_dowarn|||pn PL_errgv|5.004050||p PL_error_count|5.014000||p PL_expect|5.014000||p PL_hexdigit|5.005000||p PL_hints|5.005000||p PL_in_my_stash|5.014000||p PL_in_my|5.014000||p PL_keyword_plugin||5.011002| PL_last_in_gv|||n PL_laststatval|5.005000||p PL_lex_state|5.014000||p PL_lex_stuff|5.014000||p PL_linestr|5.014000||p PL_modglobal||5.005000|n PL_na|5.004050||pn PL_no_modify|5.006000||p PL_ofsgv|||n PL_opfreehook||5.011000|n PL_parser|5.009005|5.009005|p PL_peepp||5.007003|n PL_perl_destruct_level|5.004050||p PL_perldb|5.004050||p PL_ppaddr|5.006000||p PL_rpeepp||5.013005|n PL_rsfp_filters|5.014000||p PL_rsfp|5.014000||p PL_rs|||n PL_signals|5.008001||p PL_stack_base|5.004050||p PL_stack_sp|5.004050||p PL_statcache|5.005000||p PL_stdingv|5.004050||p PL_sv_arenaroot|5.004050||p PL_sv_no|5.004050||pn PL_sv_undef|5.004050||pn PL_sv_yes|5.004050||pn PL_tainted|5.004050||p PL_tainting|5.004050||p PL_tokenbuf|5.014000||p POP_MULTICALL||5.014000| POPi|||n POPl|||n POPn|||n POPpbytex||5.007001|n POPpx||5.005030|n POPp|||n POPs|||n PTR2IV|5.006000||p PTR2NV|5.006000||p PTR2UV|5.006000||p PTR2nat|5.009003||p PTR2ul|5.007001||p PTRV|5.006000||p PUSHMARK||| PUSH_MULTICALL||5.014000| PUSHi||| PUSHmortal|5.009002||p PUSHn||| PUSHp||| PUSHs||| PUSHu|5.004000||p PUTBACK||| PerlIO_clearerr||5.007003| PerlIO_close||5.007003| PerlIO_context_layers||5.009004| PerlIO_eof||5.007003| PerlIO_error||5.007003| PerlIO_fileno||5.007003| PerlIO_fill||5.007003| PerlIO_flush||5.007003| PerlIO_get_base||5.007003| PerlIO_get_bufsiz||5.007003| PerlIO_get_cnt||5.007003| PerlIO_get_ptr||5.007003| PerlIO_read||5.007003| PerlIO_seek||5.007003| PerlIO_set_cnt||5.007003| PerlIO_set_ptrcnt||5.007003| PerlIO_setlinebuf||5.007003| PerlIO_stderr||5.007003| PerlIO_stdin||5.007003| PerlIO_stdout||5.007003| PerlIO_tell||5.007003| PerlIO_unread||5.007003| PerlIO_write||5.007003| Perl_signbit||5.009005|n PoisonFree|5.009004||p PoisonNew|5.009004||p PoisonWith|5.009004||p Poison|5.008000||p RETVAL|||n Renewc||| Renew||| SAVECLEARSV||| SAVECOMPPAD||| SAVEPADSV||| SAVETMPS||| SAVE_DEFSV|5.004050||p SPAGAIN||| SP||| START_EXTERN_C|5.005000||p START_MY_CXT|5.007003||p STMT_END|||p STMT_START|||p STR_WITH_LEN|5.009003||p ST||| SV_CONST_RETURN|5.009003||p SV_COW_DROP_PV|5.008001||p SV_COW_SHARED_HASH_KEYS|5.009005||p SV_GMAGIC|5.007002||p SV_HAS_TRAILING_NUL|5.009004||p SV_IMMEDIATE_UNREF|5.007001||p SV_MUTABLE_RETURN|5.009003||p SV_NOSTEAL|5.009002||p SV_SMAGIC|5.009003||p SV_UTF8_NO_ENCODING|5.008001||p SVfARG|5.009005||p SVf_UTF8|5.006000||p SVf|5.006000||p SVt_IV||| SVt_NV||| SVt_PVAV||| SVt_PVCV||| SVt_PVHV||| SVt_PVMG||| SVt_PV||| Safefree||| Slab_Alloc||| Slab_Free||| Slab_to_rw||| StructCopy||| SvCUR_set||| SvCUR||| SvEND||| SvGAMAGIC||5.006001| SvGETMAGIC|5.004050||p SvGROW||| SvIOK_UV||5.006000| SvIOK_notUV||5.006000| SvIOK_off||| SvIOK_only_UV||5.006000| SvIOK_only||| SvIOK_on||| SvIOKp||| SvIOK||| SvIVX||| SvIV_nomg|5.009001||p SvIV_set||| SvIVx||| SvIV||| SvIsCOW_shared_hash||5.008003| SvIsCOW||5.008003| SvLEN_set||| SvLEN||| SvLOCK||5.007003| SvMAGIC_set|5.009003||p SvNIOK_off||| SvNIOKp||| SvNIOK||| SvNOK_off||| SvNOK_only||| SvNOK_on||| SvNOKp||| SvNOK||| SvNVX||| SvNV_nomg||5.013002| SvNV_set||| SvNVx||| SvNV||| SvOK||| SvOOK_offset||5.011000| SvOOK||| SvPOK_off||| SvPOK_only_UTF8||5.006000| SvPOK_only||| SvPOK_on||| SvPOKp||| SvPOK||| SvPVX_const|5.009003||p SvPVX_mutable|5.009003||p SvPVX||| SvPV_const|5.009003||p SvPV_flags_const_nolen|5.009003||p SvPV_flags_const|5.009003||p SvPV_flags_mutable|5.009003||p SvPV_flags|5.007002||p SvPV_force_flags_mutable|5.009003||p SvPV_force_flags_nolen|5.009003||p SvPV_force_flags|5.007002||p SvPV_force_mutable|5.009003||p SvPV_force_nolen|5.009003||p SvPV_force_nomg_nolen|5.009003||p SvPV_force_nomg|5.007002||p SvPV_force|||p SvPV_mutable|5.009003||p SvPV_nolen_const|5.009003||p SvPV_nolen|5.006000||p SvPV_nomg_const_nolen|5.009003||p SvPV_nomg_const|5.009003||p SvPV_nomg_nolen||5.013007| SvPV_nomg|5.007002||p SvPV_renew|5.009003||p SvPV_set||| SvPVbyte_force||5.009002| SvPVbyte_nolen||5.006000| SvPVbytex_force||5.006000| SvPVbytex||5.006000| SvPVbyte|5.006000||p SvPVutf8_force||5.006000| SvPVutf8_nolen||5.006000| SvPVutf8x_force||5.006000| SvPVutf8x||5.006000| SvPVutf8||5.006000| SvPVx||| SvPV||| SvREFCNT_dec||| SvREFCNT_inc_NN|5.009004||p SvREFCNT_inc_simple_NN|5.009004||p SvREFCNT_inc_simple_void_NN|5.009004||p SvREFCNT_inc_simple_void|5.009004||p SvREFCNT_inc_simple|5.009004||p SvREFCNT_inc_void_NN|5.009004||p SvREFCNT_inc_void|5.009004||p SvREFCNT_inc|||p SvREFCNT||| SvROK_off||| SvROK_on||| SvROK||| SvRV_set|5.009003||p SvRV||| SvRXOK||5.009005| SvRX||5.009005| SvSETMAGIC||| SvSHARED_HASH|5.009003||p SvSHARE||5.007003| SvSTASH_set|5.009003||p SvSTASH||| SvSetMagicSV_nosteal||5.004000| SvSetMagicSV||5.004000| SvSetSV_nosteal||5.004000| SvSetSV||| SvTAINTED_off||5.004000| SvTAINTED_on||5.004000| SvTAINTED||5.004000| SvTAINT||| SvTRUE_nomg||5.013006| SvTRUE||| SvTYPE||| SvUNLOCK||5.007003| SvUOK|5.007001|5.006000|p SvUPGRADE||| SvUTF8_off||5.006000| SvUTF8_on||5.006000| SvUTF8||5.006000| SvUVXx|5.004000||p SvUVX|5.004000||p SvUV_nomg|5.009001||p SvUV_set|5.009003||p SvUVx|5.004000||p SvUV|5.004000||p SvVOK||5.008001| SvVSTRING_mg|5.009004||p THIS|||n UNDERBAR|5.009002||p UTF8_MAXBYTES|5.009002||p UVSIZE|5.006000||p UVTYPE|5.006000||p UVXf|5.007001||p UVof|5.006000||p UVuf|5.006000||p UVxf|5.006000||p WARN_ALL|5.006000||p WARN_AMBIGUOUS|5.006000||p WARN_ASSERTIONS|5.014000||p WARN_BAREWORD|5.006000||p WARN_CLOSED|5.006000||p WARN_CLOSURE|5.006000||p WARN_DEBUGGING|5.006000||p WARN_DEPRECATED|5.006000||p WARN_DIGIT|5.006000||p WARN_EXEC|5.006000||p WARN_EXITING|5.006000||p WARN_GLOB|5.006000||p WARN_INPLACE|5.006000||p WARN_INTERNAL|5.006000||p WARN_IO|5.006000||p WARN_LAYER|5.008000||p WARN_MALLOC|5.006000||p WARN_MISC|5.006000||p WARN_NEWLINE|5.006000||p WARN_NUMERIC|5.006000||p WARN_ONCE|5.006000||p WARN_OVERFLOW|5.006000||p WARN_PACK|5.006000||p WARN_PARENTHESIS|5.006000||p WARN_PIPE|5.006000||p WARN_PORTABLE|5.006000||p WARN_PRECEDENCE|5.006000||p WARN_PRINTF|5.006000||p WARN_PROTOTYPE|5.006000||p WARN_QW|5.006000||p WARN_RECURSION|5.006000||p WARN_REDEFINE|5.006000||p WARN_REGEXP|5.006000||p WARN_RESERVED|5.006000||p WARN_SEMICOLON|5.006000||p WARN_SEVERE|5.006000||p WARN_SIGNAL|5.006000||p WARN_SUBSTR|5.006000||p WARN_SYNTAX|5.006000||p WARN_TAINT|5.006000||p WARN_THREADS|5.008000||p WARN_UNINITIALIZED|5.006000||p WARN_UNOPENED|5.006000||p WARN_UNPACK|5.006000||p WARN_UNTIE|5.006000||p WARN_UTF8|5.006000||p WARN_VOID|5.006000||p XCPT_CATCH|5.009002||p XCPT_RETHROW|5.009002||p XCPT_TRY_END|5.009002||p XCPT_TRY_START|5.009002||p XPUSHi||| XPUSHmortal|5.009002||p XPUSHn||| XPUSHp||| XPUSHs||| XPUSHu|5.004000||p XSPROTO|5.010000||p XSRETURN_EMPTY||| XSRETURN_IV||| XSRETURN_NO||| XSRETURN_NV||| XSRETURN_PV||| XSRETURN_UNDEF||| XSRETURN_UV|5.008001||p XSRETURN_YES||| XSRETURN|||p XST_mIV||| XST_mNO||| XST_mNV||| XST_mPV||| XST_mUNDEF||| XST_mUV|5.008001||p XST_mYES||| XS_APIVERSION_BOOTCHECK||5.013004| XS_VERSION_BOOTCHECK||| XS_VERSION||| XSprePUSH|5.006000||p XS||| XopDISABLE||5.014000| XopENABLE||5.014000| XopENTRY_set||5.014000| XopENTRY||5.014000| XopFLAGS||5.013007| ZeroD|5.009002||p Zero||| _aMY_CXT|5.007003||p _append_range_to_invlist||| _new_invlist||| _pMY_CXT|5.007003||p _swash_inversion_hash||| _swash_to_invlist||| aMY_CXT_|5.007003||p aMY_CXT|5.007003||p aTHXR_|5.014000||p aTHXR|5.014000||p aTHX_|5.006000||p aTHX|5.006000||p add_alternate||| add_cp_to_invlist||| add_data|||n add_range_to_invlist||| add_utf16_textfilter||| addmad||| allocmy||| amagic_call||| amagic_cmp_locale||| amagic_cmp||| amagic_deref_call||5.013007| amagic_i_ncmp||| amagic_ncmp||| anonymise_cv_maybe||| any_dup||| ao||| append_madprops||| apply_attrs_my||| apply_attrs_string||5.006001| apply_attrs||| apply||| assert_uft8_cache_coherent||| atfork_lock||5.007003|n atfork_unlock||5.007003|n av_arylen_p||5.009003| av_clear||| av_create_and_push||5.009005| av_create_and_unshift_one||5.009005| av_delete||5.006000| av_exists||5.006000| av_extend||| av_fetch||| av_fill||| av_iter_p||5.011000| av_len||| av_make||| av_pop||| av_push||| av_reify||| av_shift||| av_store||| av_undef||| av_unshift||| ax|||n bad_type||| bind_match||| block_end||| block_gimme||5.004000| block_start||| blockhook_register||5.013003| boolSV|5.004000||p boot_core_PerlIO||| boot_core_UNIVERSAL||| boot_core_mro||| bytes_cmp_utf8||5.013007| bytes_from_utf8||5.007001| bytes_to_uni|||n bytes_to_utf8||5.006001| call_argv|5.006000||p call_atexit||5.006000| call_list||5.004000| call_method|5.006000||p call_pv|5.006000||p call_sv|5.006000||p caller_cx||5.013005| calloc||5.007002|n cando||| cast_i32||5.006000| cast_iv||5.006000| cast_ulong||5.006000| cast_uv||5.006000| check_type_and_open||| check_uni||| check_utf8_print||| checkcomma||| checkposixcc||| ckWARN|5.006000||p ck_entersub_args_list||5.013006| ck_entersub_args_proto_or_list||5.013006| ck_entersub_args_proto||5.013006| ck_warner_d||5.011001|v ck_warner||5.011001|v ckwarn_common||| ckwarn_d||5.009003| ckwarn||5.009003| cl_and|||n cl_anything|||n cl_init|||n cl_is_anything|||n cl_or|||n clear_placeholders||| clone_params_del|||n clone_params_new|||n closest_cop||| convert||| cop_free||| cop_hints_2hv||5.013007| cop_hints_fetch_pvn||5.013007| cop_hints_fetch_pvs||5.013007| cop_hints_fetch_pv||5.013007| cop_hints_fetch_sv||5.013007| cophh_2hv||5.013007| cophh_copy||5.013007| cophh_delete_pvn||5.013007| cophh_delete_pvs||5.013007| cophh_delete_pv||5.013007| cophh_delete_sv||5.013007| cophh_fetch_pvn||5.013007| cophh_fetch_pvs||5.013007| cophh_fetch_pv||5.013007| cophh_fetch_sv||5.013007| cophh_free||5.013007| cophh_new_empty||5.014000| cophh_store_pvn||5.013007| cophh_store_pvs||5.013007| cophh_store_pv||5.013007| cophh_store_sv||5.013007| cr_textfilter||| create_eval_scope||| croak_no_modify||5.013003| croak_nocontext|||vn croak_sv||5.013001| croak_xs_usage||5.010001| croak|||v csighandler||5.009003|n curmad||| curse||| custom_op_desc||5.007003| custom_op_name||5.007003| custom_op_register||5.013007| custom_op_xop||5.013007| cv_ckproto_len||| cv_clone||| cv_const_sv||5.004000| cv_dump||| cv_get_call_checker||5.013006| cv_set_call_checker||5.013006| cv_undef||| cvgv_set||| cvstash_set||| cx_dump||5.005000| cx_dup||| cxinc||| dAXMARK|5.009003||p dAX|5.007002||p dITEMS|5.007002||p dMARK||| dMULTICALL||5.009003| dMY_CXT_SV|5.007003||p dMY_CXT|5.007003||p dNOOP|5.006000||p dORIGMARK||| dSP||| dTHR|5.004050||p dTHXR|5.014000||p dTHXa|5.006000||p dTHXoa|5.006000||p dTHX|5.006000||p dUNDERBAR|5.009002||p dVAR|5.009003||p dXCPT|5.009002||p dXSARGS||| dXSI32||| dXSTARG|5.006000||p deb_curcv||| deb_nocontext|||vn deb_stack_all||| deb_stack_n||| debop||5.005000| debprofdump||5.005000| debprof||| debstackptrs||5.007003| debstack||5.007003| debug_start_match||| deb||5.007003|v del_sv||| delete_eval_scope||| delimcpy||5.004000|n deprecate_commaless_var_list||| despatch_signals||5.007001| destroy_matcher||| die_nocontext|||vn die_sv||5.013001| die_unwind||| die|||v dirp_dup||| div128||| djSP||| do_aexec5||| do_aexec||| do_aspawn||| do_binmode||5.004050| do_chomp||| do_close||| do_delete_local||| do_dump_pad||| do_eof||| do_exec3||| do_execfree||| do_exec||| do_gv_dump||5.006000| do_gvgv_dump||5.006000| do_hv_dump||5.006000| do_ipcctl||| do_ipcget||| do_join||| do_magic_dump||5.006000| do_msgrcv||| do_msgsnd||| do_oddball||| do_op_dump||5.006000| do_op_xmldump||| do_open9||5.006000| do_openn||5.007001| do_open||5.004000| do_pmop_dump||5.006000| do_pmop_xmldump||| do_print||| do_readline||| do_seek||| do_semop||| do_shmio||| do_smartmatch||| do_spawn_nowait||| do_spawn||| do_sprintf||| do_sv_dump||5.006000| do_sysseek||| do_tell||| do_trans_complex_utf8||| do_trans_complex||| do_trans_count_utf8||| do_trans_count||| do_trans_simple_utf8||| do_trans_simple||| do_trans||| do_vecget||| do_vecset||| do_vop||| docatch||| doeval||| dofile||| dofindlabel||| doform||| doing_taint||5.008001|n dooneliner||| doopen_pm||| doparseform||| dopoptoeval||| dopoptogiven||| dopoptolabel||| dopoptoloop||| dopoptosub_at||| dopoptowhen||| doref||5.009003| dounwind||| dowantarray||| dump_all_perl||| dump_all||5.006000| dump_eval||5.006000| dump_exec_pos||| dump_fds||| dump_form||5.006000| dump_indent||5.006000|v dump_mstats||| dump_packsubs_perl||| dump_packsubs||5.006000| dump_sub_perl||| dump_sub||5.006000| dump_sv_child||| dump_trie_interim_list||| dump_trie_interim_table||| dump_trie||| dump_vindent||5.006000| dumpuntil||| dup_attrlist||| emulate_cop_io||| eval_pv|5.006000||p eval_sv|5.006000||p exec_failed||| expect_number||| fbm_compile||5.005000| fbm_instr||5.005000| feature_is_enabled||| fetch_cop_label||5.011000| filter_add||| filter_del||| filter_gets||| filter_read||| find_and_forget_pmops||| find_array_subscript||| find_beginning||| find_byclass||| find_hash_subscript||| find_in_my_stash||| find_runcv||5.008001| find_rundefsvoffset||5.009002| find_rundefsv||5.013002| find_script||| find_uninit_var||| first_symbol|||n foldEQ_latin1||5.013008|n foldEQ_locale||5.013002|n foldEQ_utf8_flags||5.013010| foldEQ_utf8||5.013002| foldEQ||5.013002|n fold_constants||| forbid_setid||| force_ident||| force_list||| force_next||| force_strict_version||| 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_aux_mg||| get_av|5.006000||p get_context||5.006000|n get_cvn_flags|5.009005||p get_cvs|5.011000||p get_cv|5.006000||p get_db_sub||| get_debug_opts||| get_hash_seed||| get_hv|5.006000||p get_mstats||| get_no_modify||| 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_bslash_c||| grok_bslash_o||| 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||| gv_HVadd||| gv_IOadd||| gv_SVadd||| gv_add_by_type||5.011000| gv_autoload4||5.004000| gv_check||| gv_const_sv||5.009003| gv_dump||5.006000| gv_efullname3||5.004000| gv_efullname4||5.006001| gv_efullname||| gv_ename||| gv_fetchfile_flags||5.009005| gv_fetchfile||| gv_fetchmeth_autoload||5.007003| gv_fetchmethod_autoload||5.004000| gv_fetchmethod_flags||5.011000| gv_fetchmethod||| gv_fetchmeth||| gv_fetchpvn_flags|5.009002||p gv_fetchpvs|5.009004||p gv_fetchpv||| gv_fetchsv|5.009002||p gv_fullname3||5.004000| gv_fullname4||5.006001| gv_fullname||| gv_get_super_pkg||| gv_handler||5.007001| gv_init_sv||| gv_init||| gv_magicalize_isa||| gv_magicalize_overload||| gv_name_set||5.009004| gv_stashpvn|5.004000||p gv_stashpvs|5.009003||p gv_stashpv||| gv_stashsv||| gv_try_downgrade||| he_dup||| hek_dup||| hfreeentries||| hsplit||| hv_assert||| hv_auxinit|||n hv_backreferences_p||| hv_clear_placeholders||5.009001| hv_clear||| hv_common_key_len||5.010000| hv_common||5.010000| hv_copy_hints_hv||5.009004| hv_delayfree_ent||5.004000| hv_delete_common||| hv_delete_ent||5.004000| hv_delete||| hv_eiter_p||5.009003| hv_eiter_set||5.009003| hv_ename_add||| hv_ename_delete||| hv_exists_ent||5.004000| hv_exists||| hv_fetch_ent||5.004000| hv_fetchs|5.009003||p hv_fetch||| hv_fill||5.013002| hv_free_ent||5.004000| hv_iterinit||| hv_iterkeysv||5.004000| hv_iterkey||| hv_iternext_flags||5.008000| hv_iternextsv||| hv_iternext||| hv_iterval||| hv_kill_backrefs||| hv_ksplit||5.004000| hv_magic_check|||n hv_magic||| hv_name_set||5.009003| hv_notallowed||| hv_placeholders_get||5.009003| hv_placeholders_p||5.009003| hv_placeholders_set||5.009003| hv_riter_p||5.009003| hv_riter_set||5.009003| hv_scalar||5.009001| hv_store_ent||5.004000| hv_store_flags||5.008000| hv_stores|5.009004||p hv_store||| hv_undef_flags||| hv_undef||| ibcmp_locale||5.004000| ibcmp_utf8||5.007003| ibcmp||| incline||| incpush_if_exists||| incpush_use_sep||| incpush||| ingroup||| init_argv_symbols||| init_dbargs||| 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| instr|||n intro_my||| intuit_method||| intuit_more||| invert||| invlist_array||| invlist_destroy||| invlist_extend||| invlist_intersection||| invlist_len||| invlist_max||| invlist_set_array||| invlist_set_len||| invlist_set_max||| invlist_trim||| invlist_union||| invoke_exception_hook||| io_close||| isALNUMC|5.006000||p isALPHA||| isASCII|5.006000||p isBLANK|5.006001||p isCNTRL|5.006000||p isDIGIT||| isGRAPH|5.006000||p isGV_with_GP|5.009004||p isLOWER||| isOCTAL||5.013005| isPRINT|5.004000||p isPSXSPC|5.006001||p isPUNCT|5.006000||p isSPACE||| isUPPER||| isWORDCHAR||5.013006| isXDIGIT|5.006000||p is_an_int||| is_ascii_string||5.011000|n is_gv_magical_sv||| is_handle_constructor|||n is_inplace_av||| is_list_assignment||| is_lvalue_sub||5.007001| is_uni_alnum_lc||5.006000| is_uni_alnum||5.006000| is_uni_alpha_lc||5.006000| is_uni_alpha||5.006000| is_uni_ascii_lc||5.006000| is_uni_ascii||5.006000| is_uni_cntrl_lc||5.006000| is_uni_cntrl||5.006000| is_uni_digit_lc||5.006000| is_uni_digit||5.006000| is_uni_graph_lc||5.006000| is_uni_graph||5.006000| is_uni_idfirst_lc||5.006000| is_uni_idfirst||5.006000| is_uni_lower_lc||5.006000| is_uni_lower||5.006000| is_uni_print_lc||5.006000| is_uni_print||5.006000| is_uni_punct_lc||5.006000| is_uni_punct||5.006000| is_uni_space_lc||5.006000| is_uni_space||5.006000| is_uni_upper_lc||5.006000| is_uni_upper||5.006000| is_uni_xdigit_lc||5.006000| is_uni_xdigit||5.006000| is_utf8_X_LVT||| is_utf8_X_LV_LVT_V||| is_utf8_X_LV||| is_utf8_X_L||| is_utf8_X_T||| is_utf8_X_V||| is_utf8_X_begin||| is_utf8_X_extend||| is_utf8_X_non_hangul||| is_utf8_X_prepend||| is_utf8_alnum||5.006000| is_utf8_alpha||5.006000| is_utf8_ascii||5.006000| is_utf8_char_slow|||n is_utf8_char||5.006000|n is_utf8_cntrl||5.006000| is_utf8_common||| is_utf8_digit||5.006000| is_utf8_graph||5.006000| is_utf8_idcont||5.008000| is_utf8_idfirst||5.006000| is_utf8_lower||5.006000| is_utf8_mark||5.006000| is_utf8_perl_space||5.011001| is_utf8_perl_word||5.011001| is_utf8_posix_digit||5.011001| is_utf8_print||5.006000| is_utf8_punct||5.006000| is_utf8_space||5.006000| is_utf8_string_loclen||5.009003|n is_utf8_string_loc||5.008001|n is_utf8_string||5.006001|n is_utf8_upper||5.006000| is_utf8_xdigit||5.006000| is_utf8_xidcont||5.013010| is_utf8_xidfirst||5.013010| isa_lookup||| items|||n ix|||n jmaybe||| join_exact||| keyword_plugin_standard||| keyword||| leave_scope||| lex_bufutf8||5.011002| lex_discard_to||5.011002| lex_grow_linestr||5.011002| lex_next_chunk||5.011002| lex_peek_unichar||5.011002| lex_read_space||5.011002| lex_read_to||5.011002| lex_read_unichar||5.011002| lex_start||5.009005| lex_stuff_pvn||5.011002| lex_stuff_pvs||5.013005| lex_stuff_pv||5.013006| lex_stuff_sv||5.011002| lex_unstuff||5.011002| listkids||| list||| load_module_nocontext|||vn load_module|5.006000||pv localize||| looks_like_bool||| looks_like_number||| lop||| mPUSHi|5.009002||p mPUSHn|5.009002||p mPUSHp|5.009002||p mPUSHs|5.010001||p mPUSHu|5.009002||p mXPUSHi|5.009002||p mXPUSHn|5.009002||p mXPUSHp|5.009002||p mXPUSHs|5.010001||p mXPUSHu|5.009002||p mad_free||| madlex||| madparse||| magic_clear_all_env||| magic_clearenv||| magic_clearhints||| magic_clearhint||| magic_clearisa||| magic_clearpack||| magic_clearsig||| magic_dump||5.006000| magic_existspack||| magic_freearylen_p||| magic_freeovrld||| magic_getarylen||| magic_getdefelem||| magic_getnkeys||| magic_getpack||| magic_getpos||| magic_getsig||| magic_getsubstr||| magic_gettaint||| magic_getuvar||| magic_getvec||| magic_get||| magic_killbackrefs||| magic_len||| magic_methcall1||| magic_methcall|||v magic_methpack||| magic_nextpack||| magic_regdata_cnt||| magic_regdatum_get||| magic_regdatum_set||| 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||| magic_set||| magic_sizepack||| magic_wipepack||| make_matcher||| make_trie_failtable||| make_trie||| malloc_good_size|||n malloced_size|||n malloc||5.007002|n markstack_grow||| matcher_matches_sv||| measure_struct||| memEQs|5.009005||p memEQ|5.004000||p memNEs|5.009005||p memNE|5.004000||p mem_collxfrm||| mem_log_common|||n mess_alloc||| mess_nocontext|||vn mess_sv||5.013001| mess||5.006000|v method_common||| mfree||5.007002|n mg_clear||| mg_copy||| mg_dup||| mg_findext||5.013008| mg_find||| mg_free_type||5.013006| mg_free||| mg_get||| mg_length||5.005000| mg_localize||| mg_magical||| mg_set||| mg_size||5.005000| mini_mktime||5.007002| missingterm||| mode_from_discipline||| modkids||| mod||| more_bodies||| more_sv||| moreswitches||| mro_clean_isarev||| mro_gather_and_rename||| mro_get_from_name||5.010001| mro_get_linear_isa_dfs||| mro_get_linear_isa||5.009005| mro_get_private_data||5.010001| mro_isa_changed_in||| mro_meta_dup||| mro_meta_init||| mro_method_changed_in||5.009005| mro_package_moved||| mro_register||5.010001| mro_set_mro||5.010001| mro_set_private_data||5.010001| mul128||| mulexp10|||n munge_qwlist_to_paren_list||| my_atof2||5.007002| my_atof||5.006000| my_attrs||| my_bcopy|||n my_betoh16|||n my_betoh32|||n my_betoh64|||n my_betohi|||n my_betohl|||n my_betohs|||n my_bzero|||n my_chsize||| my_clearenv||| my_cxt_index||| my_cxt_init||| my_dirfd||5.009005| my_exit_jump||| my_exit||| my_failure_exit||5.004000| my_fflush_all||5.006000| my_fork||5.007003|n my_htobe16|||n my_htobe32|||n my_htobe64|||n my_htobei|||n my_htobel|||n my_htobes|||n my_htole16|||n my_htole32|||n my_htole64|||n my_htolei|||n my_htolel|||n my_htoles|||n my_htonl||| my_kid||| my_letoh16|||n my_letoh32|||n my_letoh64|||n my_letohi|||n my_letohl|||n my_letohs|||n my_lstat_flags||| my_lstat||5.014000| my_memcmp||5.004000|n my_memset|||n my_ntohl||| my_pclose||5.004000| my_popen_list||5.007001| my_popen||5.004000| my_setenv||| my_snprintf|5.009004||pvn my_socketpair||5.007003|n my_sprintf|5.009003||pvn my_stat_flags||| my_stat||5.014000| my_strftime||5.007002| my_strlcat|5.009004||pn my_strlcpy|5.009004||pn my_swabn|||n my_swap||| my_unexec||| my_vsnprintf||5.009004|n need_utf8|||n newANONATTRSUB||5.006000| newANONHASH||| newANONLIST||| newANONSUB||| newASSIGNOP||| newATTRSUB||5.006000| newAVREF||| newAV||| newBINOP||| newCONDOP||| newCONSTSUB|5.004050||p newCVREF||| newDEFSVOP||| newFORM||| newFOROP||5.013007| newGIVENOP||5.009003| newGIVWHENOP||| newGP||| newGVOP||| newGVREF||| newGVgen||| newHVREF||| newHVhv||5.005000| newHV||| newIO||| newLISTOP||| newLOGOP||| newLOOPEX||| newLOOPOP||| newMADPROP||| newMADsv||| newMYSUB||| newNULLLIST||| newOP||| newPADOP||| newPMOP||| newPROG||| newPVOP||| newRANGE||| newRV_inc|5.004000||p newRV_noinc|5.004000||p newRV||| newSLICEOP||| newSTATEOP||| newSUB||| newSVOP||| newSVREF||| newSV_type|5.009005||p newSVhek||5.009003| newSViv||| newSVnv||| newSVpv_share||5.013006| newSVpvf_nocontext|||vn newSVpvf||5.004000|v newSVpvn_flags|5.010001||p newSVpvn_share|5.007001||p newSVpvn_utf8|5.010001||p newSVpvn|5.004050||p newSVpvs_flags|5.010001||p newSVpvs_share|5.009003||p newSVpvs|5.009003||p newSVpv||| newSVrv||| newSVsv||| newSVuv|5.006000||p newSV||| newTOKEN||| newUNOP||| newWHENOP||5.009003| newWHILEOP||5.013007| newXS_flags||5.009004| newXSproto||5.006000| newXS||5.006000| new_collate||5.006000| new_constant||| new_ctype||5.006000| new_he||| new_logop||| new_numeric||5.006000| new_stackinfo||5.005000| new_version||5.009000| new_warnings_bitfield||| next_symbol||| nextargv||| nextchar||| ninstr|||n no_bareword_allowed||| no_fh_allowed||| no_op||| not_a_number||| nothreadhook||5.008000| nuke_stacks||| num_overflow|||n oopsAV||| oopsHV||| op_append_elem||5.013006| op_append_list||5.013006| op_clear||| op_const_sv||| op_contextualize||5.013006| op_dump||5.006000| op_free||| op_getmad_weak||| op_getmad||| op_linklist||5.013006| op_lvalue||5.013007| op_null||5.007002| op_prepend_elem||5.013006| op_refcnt_dec||| op_refcnt_inc||| op_refcnt_lock||5.009002| op_refcnt_unlock||5.009002| op_scope||5.013007| op_xmldump||| open_script||| opt_scalarhv||| pMY_CXT_|5.007003||p pMY_CXT|5.007003||p pTHX_|5.006000||p pTHX|5.006000||p packWARN|5.007003||p pack_cat||5.007003| pack_rec||| package_version||| package||| packlist||5.008001| pad_add_anon||| pad_add_name_sv||| pad_add_name||| pad_alloc||| pad_block_start||| pad_check_dup||| pad_compname_type||| pad_findlex||| pad_findmy||5.011002| pad_fixup_inner_anons||| pad_free||| pad_leavemy||| pad_new||| pad_peg|||n pad_push||| pad_reset||| pad_setsv||| pad_sv||| pad_swipe||| pad_tidy||| padlist_dup||| parse_arithexpr||5.013008| parse_barestmt||5.013007| parse_block||5.013007| parse_body||| parse_fullexpr||5.013008| parse_fullstmt||5.013005| parse_label||5.013007| parse_listexpr||5.013008| parse_stmtseq||5.013006| parse_termexpr||5.013008| parse_unicode_opts||| parser_dup||| parser_free||| path_is_absolute|||n peep||| pending_Slabs_to_ro||| perl_alloc_using|||n perl_alloc|||n perl_clone_using|||n perl_clone|||n perl_construct|||n perl_destruct||5.007003|n perl_free|||n perl_parse||5.006000|n perl_run|||n pidgone||| pm_description||| pmop_dump||5.006000| pmop_xmldump||| pmruntime||| pmtrans||| pop_scope||| populate_isa|||v pregcomp||5.009005| pregexec||| pregfree2||5.011000| pregfree||| prepend_madprops||| prescan_version||5.011004| printbuf||| printf_nocontext|||vn process_special_blocks||| ptr_table_clear||5.009005| ptr_table_fetch||5.009005| ptr_table_find|||n ptr_table_free||5.009005| ptr_table_new||5.009005| ptr_table_split||5.009005| ptr_table_store||5.009005| push_scope||| put_byte||| pv_display|5.006000||p pv_escape|5.009004||p pv_pretty|5.009004||p pv_uni_display||5.007003| qerror||| qsortsvu||| re_compile||5.009005| re_croak2||| re_dup_guts||| re_intuit_start||5.009005| re_intuit_string||5.006000| readpipe_override||| realloc||5.007002|n reentrant_free||| reentrant_init||| reentrant_retry|||vn reentrant_size||| ref_array_or_hash||| refcounted_he_chain_2hv||| refcounted_he_fetch_pvn||| refcounted_he_fetch_pvs||| refcounted_he_fetch_pv||| refcounted_he_fetch_sv||| refcounted_he_free||| refcounted_he_inc||| refcounted_he_new_pvn||| refcounted_he_new_pvs||| refcounted_he_new_pv||| refcounted_he_new_sv||| refcounted_he_value||| refkids||| refto||| ref||5.014000| reg_check_named_buff_matched||| reg_named_buff_all||5.009005| reg_named_buff_exists||5.009005| reg_named_buff_fetch||5.009005| reg_named_buff_firstkey||5.009005| reg_named_buff_iter||| reg_named_buff_nextkey||5.009005| reg_named_buff_scalar||5.009005| reg_named_buff||| reg_namedseq||| reg_node||| reg_numbered_buff_fetch||| reg_numbered_buff_length||| reg_numbered_buff_store||| reg_qr_package||| reg_recode||| reg_scan_name||| reg_skipcomment||| reg_temp_copy||| reganode||| regatom||| regbranch||| regclass_swash||5.009004| regclass||| regcppop||| regcppush||| regcurly||| regdump_extflags||| regdump||5.005000| regdupe_internal||| regexec_flags||5.005000| regfree_internal||5.009005| reghop3|||n reghop4|||n reghopmaybe3|||n reginclass||| reginitcolors||5.006000| reginsert||| regmatch||| regnext||5.005000| regpiece||| regpposixcc||| regprop||| regrepeat||| regtail_study||| regtail||| regtry||| reguni||| regwhite|||n reg||| repeatcpy|||n report_evil_fh||| report_uninit||| report_wrongway_fh||| require_pv||5.006000| require_tie_mod||| restore_magic||| rninstr|||n rpeep||| rsignal_restore||| rsignal_save||| rsignal_state||5.004000| rsignal||5.004000| run_body||| run_user_filter||| runops_debug||5.005000| runops_standard||5.005000| rv2cv_op_cv||5.013006| rvpv_dup||| rxres_free||| rxres_restore||| rxres_save||| safesyscalloc||5.006000|n safesysfree||5.006000|n safesysmalloc||5.006000|n safesysrealloc||5.006000|n same_dirent||| save_I16||5.004000| save_I32||| save_I8||5.006000| save_adelete||5.011000| save_aelem_flags||5.011000| save_aelem||5.004050| save_alloc||5.006000| save_aptr||| save_ary||| save_bool||5.008001| save_clearsv||| save_delete||| save_destructor_x||5.006000| save_destructor||5.006000| save_freeop||| save_freepv||| save_freesv||| save_generic_pvref||5.006001| save_generic_svref||5.005030| save_gp||5.004000| save_hash||| save_hdelete||5.011000| save_hek_flags|||n save_helem_flags||5.011000| save_helem||5.004050| save_hints||5.010001| save_hptr||| save_int||| save_item||| save_iv||5.005000| save_lines||| save_list||| save_long||| save_magic||| save_mortalizesv||5.007001| save_nogv||| save_op||5.005000| save_padsv_and_mortalize||5.010001| save_pptr||| save_pushi32ptr||5.010001| save_pushptri32ptr||| save_pushptrptr||5.010001| save_pushptr||5.010001| save_re_context||5.006000| save_scalar_at||| save_scalar||| save_set_svflags||5.009000| save_shared_pvref||5.007003| save_sptr||| save_svref||| save_vptr||5.006000| savepvn||| savepvs||5.009003| savepv||| savesharedpvn||5.009005| savesharedpvs||5.013006| savesharedpv||5.007003| savesharedsvpv||5.013006| savestack_grow_cnt||5.008001| savestack_grow||| savesvpv||5.009002| sawparens||| scalar_mod_type|||n scalarboolean||| scalarkids||| scalarseq||| scalarvoid||| scalar||| scan_bin||5.006000| scan_commit||| scan_const||| scan_formline||| scan_heredoc||| scan_hex||| scan_ident||| scan_inputsymbol||| scan_num||5.007001| scan_oct||| scan_pat||| scan_str||| scan_subst||| scan_trans||| scan_version||5.009001| scan_vstring||5.009005| scan_word||| screaminstr||5.005000| search_const||| seed||5.008001| sequence_num||| sequence_tail||| sequence||| set_context||5.006000|n set_numeric_local||5.006000| set_numeric_radix||5.006000| set_numeric_standard||5.006000| set_regclass_bit_fold||| set_regclass_bit||| setdefout||| share_hek_flags||| share_hek||5.004000| si_dup||| sighandler|||n simplify_sort||| skipspace0||| skipspace1||| skipspace2||| skipspace||| 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.014000| stdize_locale||| store_cop_label||| strEQ||| strGE||| strGT||| strLE||| strLT||| strNE||| str_to_version||5.006000| strip_return||| strnEQ||| strnNE||| study_chunk||| sub_crush_depth||| sublex_done||| sublex_push||| sublex_start||| sv_2bool_flags||5.013006| sv_2bool||| sv_2cv||| sv_2io||| sv_2iuv_common||| sv_2iuv_non_preserve||| sv_2iv_flags||5.009001| sv_2iv||| sv_2mortal||| sv_2num||| sv_2nv_flags||5.013001| sv_2pv_flags|5.007002||p sv_2pv_nolen|5.006000||p sv_2pvbyte_nolen|5.006000||p sv_2pvbyte|5.006000||p sv_2pvutf8_nolen||5.006000| sv_2pvutf8||5.006000| sv_2pv||| sv_2uv_flags||5.009001| sv_2uv|5.004000||p sv_add_arena||| sv_add_backref||| sv_backoff||| sv_bless||| sv_cat_decode||5.008001| sv_catpv_flags||5.013006| sv_catpv_mg|5.004050||p sv_catpv_nomg||5.013006| sv_catpvf_mg_nocontext|||pvn sv_catpvf_mg|5.006000|5.004000|pv sv_catpvf_nocontext|||vn sv_catpvf||5.004000|v sv_catpvn_flags||5.007002| sv_catpvn_mg|5.004050||p sv_catpvn_nomg|5.007002||p sv_catpvn||| sv_catpvs_flags||5.013006| sv_catpvs_mg||5.013006| sv_catpvs_nomg||5.013006| sv_catpvs|5.009003||p sv_catpv||| sv_catsv_flags||5.007002| sv_catsv_mg|5.004050||p sv_catsv_nomg|5.007002||p sv_catsv||| sv_catxmlpvn||| sv_catxmlpv||| sv_catxmlsv||| sv_chop||| sv_clean_all||| sv_clean_objs||| sv_clear||| sv_cmp_flags||5.013006| sv_cmp_locale_flags||5.013006| sv_cmp_locale||5.004000| sv_cmp||| sv_collxfrm_flags||5.013006| sv_collxfrm||| sv_compile_2op_is_broken||| sv_compile_2op||5.008001| sv_copypv||5.007003| sv_dec_nomg||5.013002| sv_dec||| sv_del_backref||| sv_derived_from||5.004000| sv_destroyable||5.010000| sv_does||5.009004| sv_dump||| sv_dup_common||| sv_dup_inc_multiple||| sv_dup_inc||| sv_dup||| sv_eq_flags||5.013006| sv_eq||| sv_exp_grow||| sv_force_normal_flags||5.007001| sv_force_normal||5.006000| sv_free2||| sv_free_arenas||| sv_free||| sv_gets||5.004000| sv_grow||| sv_i_ncmp||| sv_inc_nomg||5.013002| sv_inc||| sv_insert_flags||5.010001| sv_insert||| sv_isa||| sv_isobject||| sv_iv||5.005000| sv_kill_backrefs||| sv_len_utf8||5.006000| sv_len||| sv_magic_portable|5.014000|5.004000|p sv_magicext||5.007003| sv_magic||| sv_mortalcopy||| sv_ncmp||| sv_newmortal||| sv_newref||| sv_nolocking||5.007003| sv_nosharing||5.007003| sv_nounlocking||| sv_nv||5.005000| sv_peek||5.005000| sv_pos_b2u_midway||| sv_pos_b2u||5.006000| sv_pos_u2b_cached||| sv_pos_u2b_flags||5.011005| sv_pos_u2b_forwards|||n sv_pos_u2b_midway|||n sv_pos_u2b||5.006000| sv_pvbyten_force||5.006000| sv_pvbyten||5.006000| sv_pvbyte||5.006000| sv_pvn_force_flags|5.007002||p sv_pvn_force||| sv_pvn_nomg|5.007003|5.005000|p sv_pvn||5.005000| sv_pvutf8n_force||5.006000| sv_pvutf8n||5.006000| sv_pvutf8||5.006000| sv_pv||5.006000| sv_recode_to_utf8||5.007003| sv_reftype||| sv_release_COW||| sv_replace||| sv_report_used||| sv_reset||| sv_rvweaken||5.006000| sv_setiv_mg|5.004050||p sv_setiv||| sv_setnv_mg|5.006000||p sv_setnv||| sv_setpv_mg|5.004050||p sv_setpvf_mg_nocontext|||pvn sv_setpvf_mg|5.006000|5.004000|pv sv_setpvf_nocontext|||vn sv_setpvf||5.004000|v sv_setpviv_mg||5.008001| sv_setpviv||5.008001| sv_setpvn_mg|5.004050||p sv_setpvn||| sv_setpvs_mg||5.013006| sv_setpvs|5.009004||p sv_setpv||| sv_setref_iv||| sv_setref_nv||| sv_setref_pvn||| sv_setref_pvs||5.013006| sv_setref_pv||| sv_setref_uv||5.007001| 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_unmagicext||5.013008| 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| sv_utf8_downgrade||5.006000| sv_utf8_encode||5.006000| sv_utf8_upgrade_flags_grow||5.011000| sv_utf8_upgrade_flags||5.007002| sv_utf8_upgrade_nomg||5.007002| sv_utf8_upgrade||5.007001| sv_uv|5.005000||p sv_vcatpvf_mg|5.006000|5.004000|p sv_vcatpvfn||5.004000| sv_vcatpvf|5.006000|5.004000|p sv_vsetpvf_mg|5.006000|5.004000|p sv_vsetpvfn||5.004000| sv_vsetpvf|5.006000|5.004000|p sv_xmlpeek||| svtype||| swallow_bom||| swash_fetch||5.007002| swash_get||| swash_init||5.006000| sys_init3||5.010000|n sys_init||5.010000|n sys_intern_clear||| sys_intern_dup||| sys_intern_init||| sys_term||5.010000|n taint_env||| taint_proper||| tied_method|||v tmps_grow||5.006000| toLOWER||| toUPPER||| to_byte_substr||| to_uni_fold||5.007003| to_uni_lower_lc||5.006000| to_uni_lower||5.007003| to_uni_title_lc||5.006000| to_uni_title||5.007003| to_uni_upper_lc||5.006000| to_uni_upper||5.007003| to_utf8_case||5.007003| to_utf8_fold||5.007003| to_utf8_lower||5.007003| to_utf8_substr||| to_utf8_title||5.007003| to_utf8_upper||5.007003| token_free||| token_getmad||| tokenize_use||| tokeq||| tokereport||| too_few_arguments||| too_many_arguments||| try_amagic_bin||| try_amagic_un||| uiv_2buf|||n unlnk||| unpack_rec||| unpack_str||5.007003| unpackstring||5.008001| unreferenced_to_tmp_stack||| unshare_hek_or_pvn||| unshare_hek||| unsharepvn||5.004000| unwind_handler_stack||| update_debugger_info||| upg_version||5.009005| usage||| utf16_textfilter||| utf16_to_utf8_reversed||5.006001| utf16_to_utf8||5.006001| utf8_distance||5.006000| utf8_hop||5.006000| utf8_length||5.007001| utf8_mg_len_cache_update||| utf8_mg_pos_cache_update||| utf8_to_bytes||5.006001| utf8_to_uvchr||5.007001| utf8_to_uvuni||5.007001| utf8n_to_uvchr||| utf8n_to_uvuni||5.007001| utilize||| uvchr_to_utf8_flags||5.007003| uvchr_to_utf8||| uvuni_to_utf8_flags||5.007003| uvuni_to_utf8||5.007001| validate_suid||| varname||| vcmp||5.009000| vcroak||5.006000| vdeb||5.007003| vform||5.006000| visit||| vivify_defelem||| vivify_ref||| vload_module|5.006000||p vmess||5.006000| vnewSVpvf|5.006000|5.004000|p vnormal||5.009002| vnumify||5.009000| vstringify||5.009000| vverify||5.009003| vwarner||5.006000| vwarn||5.006000| wait4pid||| warn_nocontext|||vn warn_sv||5.013001| warner_nocontext|||vn warner|5.006000|5.004000|pv warn|||v watch||| whichsig||| with_queued_errors||| write_no_mem||| write_to_stderr||| xmldump_all_perl||| xmldump_all||| xmldump_attr||| xmldump_eval||| xmldump_form||| xmldump_indent|||v xmldump_packsubs_perl||| xmldump_packsubs||| xmldump_sub_perl||| xmldump_sub||| xmldump_vindent||| xs_apiversion_bootcheck||| xs_version_bootcheck||| yyerror||| yylex||| yyparse||| yyunlex||| yywarn||| ); if (exists $opt{'list-unsupported'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{todo}; print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n"; } exit 0; } # Scan for possible replacement candidates my(%replace, %need, %hints, %warnings, %depends); my $replace = 0; my($hint, $define, $function); sub find_api { my $code = shift; $code =~ s{ / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*) | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx; grep { exists $API{$_} } $code =~ /(\w+)/mg; } while () { if ($hint) { my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings; if (m{^\s*\*\s(.*?)\s*$}) { for (@{$hint->[1]}) { $h->{$_} ||= ''; # suppress warning with older perls $h->{$_} .= "$1\n"; } } else { undef $hint } } $hint = [$1, [split /,?\s+/, $2]] if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}; if ($define) { if ($define->[1] =~ /\\$/) { $define->[1] .= $_; } else { if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) { my @n = find_api($define->[1]); push @{$depends{$define->[0]}}, @n if @n } undef $define; } } $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)}; if ($function) { if (/^}/) { if (exists $API{$function->[0]}) { my @n = find_api($function->[1]); push @{$depends{$function->[0]}}, @n if @n } undef $function; } else { $function->[1] .= $_; } } $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)}; $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$}; $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)}; $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce}; $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$}; if (m{^\s*$rccs\s+(\w+(\s*,\s*\w+)*)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) { my @deps = map { s/\s+//g; $_ } split /,/, $3; my $d; for $d (map { s/\s+//g; $_ } split /,/, $1) { push @{$depends{$d}}, @deps; } } $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)}; } for (values %depends) { my %s; $_ = [sort grep !$s{$_}++, @$_]; } if (exists $opt{'api-info'}) { my $f; my $count = 0; my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$"; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $f =~ /$match/; print "\n=== $f ===\n\n"; my $info = 0; if ($API{$f}{base} || $API{$f}{todo}) { my $base = format_version($API{$f}{base} || $API{$f}{todo}); print "Supported at least starting from perl-$base.\n"; $info++; } if ($API{$f}{provided}) { my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003"; print "Support by $ppport provided back to perl-$todo.\n"; print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f}; print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f}; print "\n$hints{$f}" if exists $hints{$f}; print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f}; $info++; } print "No portability information available.\n" unless $info; $count++; } $count or print "Found no API matching '$opt{'api-info'}'."; print "\n"; exit 0; } if (exists $opt{'list-provided'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{provided}; my @flags; push @flags, 'explicit' if exists $need{$f}; push @flags, 'depend' if exists $depends{$f}; push @flags, 'hint' if exists $hints{$f}; push @flags, 'warning' if exists $warnings{$f}; my $flags = @flags ? ' ['.join(', ', @flags).']' : ''; print "$f$flags\n"; } exit 0; } my @files; my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc ); my $srcext = join '|', map { quotemeta $_ } @srcext; 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; } info("Scanning $filename ..."); my $c = do { local $/; }; close IN; my %file = (orig => $c, changes => 0); # Temporarily remove C/XS comments and strings from the code my @ccom; $c =~ s{ ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]* | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* ) | ( ^$HS*\#[^\r\n]* | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) ) }{ defined $2 and push @ccom, $2; defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex; $file{ccom} = \@ccom; $file{code} = $c; $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m; my $func; for $func (keys %API) { my $match = $func; $match .= "|$revreplace{$func}" if exists $revreplace{$func}; if ($c =~ /\b(?:Perl_)?($match)\b/) { $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func}; $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/; if (exists $API{$func}{provided}) { $file{uses_provided}{$func}++; if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) { $file{uses}{$func}++; my @deps = rec_depend($func); if (@deps) { $file{uses_deps}{$func} = \@deps; for (@deps) { $file{uses}{$_} = 0 unless exists $file{uses}{$_}; } } for ($func, @deps) { $file{needs}{$_} = 'static' if exists $need{$_}; } } } 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 ==="); my %file = %{$files{$filename}}; my $func; my $c = $file{code}; my $warnings = 0; for $func (sort keys %{$file{uses_Perl}}) { if ($API{$func}{varargs}) { unless ($API{$func}{nothxarg}) { my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))} { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge); if ($changes) { warning("Doesn't pass interpreter argument aTHX to Perl_$func"); $file{changes} += $changes; } } } else { warning("Uses Perl_$func instead of $func"); $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*} {$func$1(}g); } } for $func (sort keys %{$file{uses_replace}}) { warning("Uses $func instead of $replace{$func}"); $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g); } for $func (sort keys %{$file{uses_provided}}) { if ($file{uses}{$func}) { if (exists $file{uses_deps}{$func}) { diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}})); } else { diag("Uses $func"); } } $warnings += hint($func); } unless ($opt{quiet}) { for $func (sort keys %{$file{uses_todo}}) { print "*** WARNING: Uses $func, which may not be portable below perl ", format_version($API{$func}{todo}), ", even with '$ppport'\n"; $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 = ''; $file{changes}++; } unless ($file{has_inc_ppport}) { diag("Needs to include '$ppport'"); $pp .= qq(#include "$ppport"\n) } if ($pp) { $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms) || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m) || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m) || ($c =~ s/^/$pp/); } } else { if ($file{has_inc_ppport}) { diag("No need to include '$ppport'"); $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m); } } # put back in our C comments my $ix; my $cppc = 0; my @ccom = @{$file{ccom}}; for $ix (0 .. $#ccom) { if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) { $cppc++; $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/; } else { $c =~ s/$rccs$ix$rcce/$ccom[$ix]/; } } if ($cppc) { my $s = $cppc != 1 ? 's' : ''; warning("Uses $cppc C++ style comment$s, which is not portable"); } my $s = $warnings != 1 ? 's' : ''; my $warn = $warnings ? " ($warnings warning$s)" : ''; info("Analysis completed$warn"); if ($file{changes}) { if (exists $opt{copy}) { my $newfile = "$filename$opt{copy}"; if (-e $newfile) { error("'$newfile' already exists, refusing to write copy of '$filename'"); } else { local *F; if (open F, ">$newfile") { info("Writing copy of '$filename' with changes to '$newfile'"); print F $c; close F; } else { error("Cannot open '$newfile' for writing: $!"); } } } elsif (exists $opt{patch} || $opt{changes}) { if (exists $opt{patch}) { unless ($patch_opened) { if (open PATCH, ">$opt{patch}") { $patch_opened = 1; } else { error("Cannot open '$opt{patch}' for writing: $!"); delete $opt{patch}; $opt{changes} = 1; goto fallback; } } mydiff(\*PATCH, $filename, $c); } else { fallback: info("Suggested changes:"); mydiff(\*STDOUT, $filename, $c); } } else { my $s = $file{changes} == 1 ? '' : 's'; info("$file{changes} potentially required change$s detected"); } } else { info("Looks good"); } } close PATCH if $patch_opened; exit 0; sub try_use { eval "use @_;"; return $@ eq '' } sub mydiff { local *F = shift; my($file, $str) = @_; my $diff; if (exists $opt{diff}) { $diff = run_diff($opt{diff}, $file, $str); } if (!defined $diff and try_use('Text::Diff')) { $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' }); $diff = <
$tmp") { print F $str; close F; if (open F, "$prog $file $tmp |") { while () { s/\Q$tmp\E/$file.patched/; $diff .= $_; } close F; unlink $tmp; return $diff; } unlink $tmp; } else { error("Cannot open '$tmp' for writing: $!"); } return undef; } sub rec_depend { my($func, $seen) = @_; return () unless exists $depends{$func}; $seen = {%{$seen||{}}}; return () if $seen->{$func}++; my %s; grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}}; } sub parse_version { my $ver = shift; if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) { return ($1, $2, $3); } elsif ($ver !~ /^\d+\.[\d_]+$/) { die "cannot parse version '$ver'\n"; } $ver =~ s/_//g; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "cannot parse version '$ver'\n"; } } return ($r, $v, $s); } sub format_version { my $ver = shift; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "invalid version '$ver'\n"; } $s /= 10; $ver = sprintf "%d.%03d", $r, $v; $s > 0 and $ver .= sprintf "_%02d", $s; return $ver; } return sprintf "%d.%d.%d", $r, $v, $s; } sub info { $opt{quiet} and return; print @_, "\n"; } sub diag { $opt{quiet} and return; $opt{diag} and print @_, "\n"; } sub warning { $opt{quiet} and return; print "*** ", @_, "\n"; } sub error { print "*** ERROR: ", @_, "\n"; } my %given_hints; my %given_warnings; sub hint { $opt{quiet} and return; my $func = shift; my $rv = 0; if (exists $warnings{$func} && !$given_warnings{$func}++) { my $warn = $warnings{$func}; $warn =~ s!^!*** !mg; print "*** WARNING: $func\n", $warn; $rv++; } if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) { my $hint = $hints{$func}; $hint =~ s/^/ /mg; print " --- hint for $func ---\n", $hint; } $rv; } sub usage { my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms; my %M = ( 'I' => '*' ); $usage =~ s/^\s*perl\s+\S+/$^X $0/; $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g; print < }; my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms; $copy =~ s/^(?=\S+)/ /gms; $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms; $self =~ s/^SKIP.*(?=^__DATA__)/SKIP if (\@ARGV && \$ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; \$@ and die "Cannot require Devel::PPPort, please install.\\n"; if (eval \$Devel::PPPort::VERSION < $VERSION) { die "$0 was originally generated with Devel::PPPort $VERSION.\\n" . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n" . "Please install a newer version, or --unstrip will not work.\\n"; } Devel::PPPort::WriteFile(\$0); exit 0; } print <$0" or die "cannot strip $0: $!\n"; print OUT "$pl$c\n"; exit 0; } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef DPPP_NAMESPACE # define DPPP_NAMESPACE DPPP_ #endif #define DPPP_CAT2(x,y) CAT2(x,y) #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name) #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) /* Replace: 1 */ # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION /* Replace PERL_PATCHLEVEL with PERL_VERSION */ /* Replace: 0 */ # endif #endif #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) /* It is very unlikely that anyone will try to use this with Perl 6 (or greater), but who knows. */ #if PERL_REVISION != 5 # error ppport.h only works with Perl version 5 #endif /* PERL_REVISION != 5 */ #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP #endif #ifndef dTHXa # define dTHXa(x) dNOOP #endif #ifndef pTHX # define pTHX void #endif #ifndef pTHX_ # define pTHX_ #endif #ifndef aTHX # define aTHX #endif #ifndef aTHX_ # define aTHX_ #endif #if (PERL_BCDVERSION < 0x5006000) # ifdef USE_THREADS # define aTHXR thr # define aTHXR_ thr, # else # define aTHXR # define aTHXR_ # endif # define dTHXR dTHR #else # define aTHXR aTHX # define aTHXR_ aTHX_ # define dTHXR dTHX #endif #ifndef dTHXoa # define dTHXoa(x) dTHXa(x) #endif #ifdef I_LIMITS # include #endif #ifndef PERL_UCHAR_MIN # define PERL_UCHAR_MIN ((unsigned char)0) #endif #ifndef PERL_UCHAR_MAX # ifdef UCHAR_MAX # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) # else # ifdef MAXUCHAR # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) # else # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) # endif # endif #endif #ifndef PERL_USHORT_MIN # define PERL_USHORT_MIN ((unsigned short)0) #endif #ifndef PERL_USHORT_MAX # ifdef USHORT_MAX # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) # else # ifdef MAXUSHORT # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) # else # ifdef USHRT_MAX # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) # else # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) # endif # endif # endif #endif #ifndef PERL_SHORT_MAX # ifdef SHORT_MAX # define PERL_SHORT_MAX ((short)SHORT_MAX) # else # ifdef MAXSHORT /* Often used in */ # define PERL_SHORT_MAX ((short)MAXSHORT) # else # ifdef SHRT_MAX # define PERL_SHORT_MAX ((short)SHRT_MAX) # else # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) # endif # endif # endif #endif #ifndef PERL_SHORT_MIN # ifdef SHORT_MIN # define PERL_SHORT_MIN ((short)SHORT_MIN) # else # ifdef MINSHORT # define PERL_SHORT_MIN ((short)MINSHORT) # else # ifdef SHRT_MIN # define PERL_SHORT_MIN ((short)SHRT_MIN) # else # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif #ifndef PERL_UINT_MAX # ifdef UINT_MAX # define PERL_UINT_MAX ((unsigned int)UINT_MAX) # else # ifdef MAXUINT # define PERL_UINT_MAX ((unsigned int)MAXUINT) # else # define PERL_UINT_MAX (~(unsigned int)0) # endif # endif #endif #ifndef PERL_UINT_MIN # define PERL_UINT_MIN ((unsigned int)0) #endif #ifndef PERL_INT_MAX # ifdef INT_MAX # define PERL_INT_MAX ((int)INT_MAX) # else # ifdef MAXINT /* Often used in */ # define PERL_INT_MAX ((int)MAXINT) # else # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) # endif # endif #endif #ifndef PERL_INT_MIN # ifdef INT_MIN # define PERL_INT_MIN ((int)INT_MIN) # else # ifdef MININT # define PERL_INT_MIN ((int)MININT) # else # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) # endif # endif #endif #ifndef PERL_ULONG_MAX # ifdef ULONG_MAX # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) # else # ifdef MAXULONG # define PERL_ULONG_MAX ((unsigned long)MAXULONG) # else # define PERL_ULONG_MAX (~(unsigned long)0) # endif # endif #endif #ifndef PERL_ULONG_MIN # define PERL_ULONG_MIN ((unsigned long)0L) #endif #ifndef PERL_LONG_MAX # ifdef LONG_MAX # define PERL_LONG_MAX ((long)LONG_MAX) # else # ifdef MAXLONG # define PERL_LONG_MAX ((long)MAXLONG) # else # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) # endif # endif #endif #ifndef PERL_LONG_MIN # ifdef LONG_MIN # define PERL_LONG_MIN ((long)LONG_MIN) # else # ifdef MINLONG # define PERL_LONG_MIN ((long)MINLONG) # else # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) # endif # endif #endif #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) # ifndef PERL_UQUAD_MAX # ifdef ULONGLONG_MAX # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) # else # ifdef MAXULONGLONG # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) # else # define PERL_UQUAD_MAX (~(unsigned long long)0) # endif # endif # endif # ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN ((unsigned long long)0L) # endif # ifndef PERL_QUAD_MAX # ifdef LONGLONG_MAX # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) # else # ifdef MAXLONGLONG # define PERL_QUAD_MAX ((long long)MAXLONGLONG) # else # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) # endif # endif # endif # ifndef PERL_QUAD_MIN # ifdef LONGLONG_MIN # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) # else # ifdef MINLONGLONG # define PERL_QUAD_MIN ((long long)MINLONGLONG) # else # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif /* This is based on code from 5.003 perl.h */ #ifdef HAS_QUAD # ifdef cray #ifndef IVTYPE # define IVTYPE int #endif #ifndef IV_MIN # define IV_MIN PERL_INT_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_INT_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UINT_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UINT_MAX #endif # ifdef INTSIZE #ifndef IVSIZE # define IVSIZE INTSIZE #endif # endif # else # if defined(convex) || defined(uts) #ifndef IVTYPE # define IVTYPE long long #endif #ifndef IV_MIN # define IV_MIN PERL_QUAD_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_QUAD_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UQUAD_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UQUAD_MAX #endif # ifdef LONGLONGSIZE #ifndef IVSIZE # define IVSIZE LONGLONGSIZE #endif # endif # else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif # ifdef LONGSIZE #ifndef IVSIZE # define IVSIZE LONGSIZE #endif # endif # endif # endif #ifndef IVSIZE # define IVSIZE 8 #endif #ifndef PERL_QUAD_MIN # define PERL_QUAD_MIN IV_MIN #endif #ifndef PERL_QUAD_MAX # define PERL_QUAD_MAX IV_MAX #endif #ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN UV_MIN #endif #ifndef PERL_UQUAD_MAX # define PERL_UQUAD_MAX UV_MAX #endif #else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef UVTYPE # define UVTYPE unsigned IVTYPE #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef sv_setuv # define sv_setuv(sv, uv) \ STMT_START { \ UV TeMpUv = uv; \ if (TeMpUv <= IV_MAX) \ sv_setiv(sv, TeMpUv); \ else \ sv_setnv(sv, (double)TeMpUv); \ } STMT_END #endif #ifndef newSVuv # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) #endif #ifndef sv_2uv # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) #endif #ifndef SvUVX # define SvUVX(sv) ((UV)SvIVX(sv)) #endif #ifndef SvUVXx # define SvUVXx(sv) SvUVX(sv) #endif #ifndef SvUV # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) #endif #ifndef SvUVx # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) #endif /* Hint: sv_uv * Always use the SvUVx() macro instead of sv_uv(). */ #ifndef sv_uv # define sv_uv(sv) SvUVx(sv) #endif #if !defined(SvUOK) && defined(SvIOK_UV) # define SvUOK(sv) SvIOK_UV(sv) #endif #ifndef XST_mUV # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) #endif #ifndef XSRETURN_UV # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END #endif #ifndef PUSHu # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END #endif #ifndef XPUSHu # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END #endif #ifdef HAS_MEMCMP #ifndef memNE # define memNE(s1,s2,l) (memcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) #endif #else #ifndef memNE # define memNE(s1,s2,l) (bcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) #endif #endif #ifndef memEQs # define memEQs(s1, l, s2) \ (sizeof(s2)-1 == l && memEQ(s1, (s2 ""), (sizeof(s2)-1))) #endif #ifndef memNEs # define memNEs(s1, l, s2) !memEQs(s1, l, s2) #endif #ifndef MoveD # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifndef CopyD # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifdef HAS_MEMSET #ifndef ZeroD # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) #endif #else #ifndef ZeroD # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) #endif #endif #ifndef PoisonWith # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) #endif #ifndef PoisonNew # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) #endif #ifndef PoisonFree # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) #endif #ifndef Poison # define Poison(d,n,t) PoisonFree(d,n,t) #endif #ifndef Newx # define Newx(v,n,t) New(0,v,n,t) #endif #ifndef Newxc # define Newxc(v,n,t,c) Newc(0,v,n,t,c) #endif #ifndef Newxz # define Newxz(v,n,t) Newz(0,v,n,t) #endif #ifndef PERL_UNUSED_DECL # ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif # else # define PERL_UNUSED_DECL # endif #endif #ifndef PERL_UNUSED_ARG # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ # include # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else # define PERL_UNUSED_ARG(x) ((void)x) # endif #endif #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(x) ((void)x) #endif #ifndef PERL_UNUSED_CONTEXT # ifdef USE_ITHREADS # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl) # else # define PERL_UNUSED_CONTEXT # endif #endif #ifndef NOOP # define NOOP /*EMPTY*/(void)0 #endif #ifndef dNOOP # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif #endif #ifndef PTR2ul # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif #ifndef PTR2nat # define PTR2nat(p) (PTRV)(p) #endif #ifndef NUM2PTR # define NUM2PTR(any,d) (any)PTR2nat(d) #endif #ifndef PTR2IV # define PTR2IV(p) INT2PTR(IV,p) #endif #ifndef PTR2UV # define PTR2UV(p) INT2PTR(UV,p) #endif #ifndef PTR2NV # define PTR2NV(p) NUM2PTR(NV,p) #endif #undef START_EXTERN_C #undef END_EXTERN_C #undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } # define EXTERN_C extern "C" #else # define START_EXTERN_C # define END_EXTERN_C # define EXTERN_C extern #endif #if defined(PERL_GCC_PEDANTIC) # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN # define PERL_GCC_BRACE_GROUPS_FORBIDDEN # endif #endif #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus) # ifndef PERL_USE_GCC_BRACE_GROUPS # define PERL_USE_GCC_BRACE_GROUPS # endif #endif #undef STMT_START #undef STMT_END #ifdef PERL_USE_GCC_BRACE_GROUPS # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ # define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) # define STMT_START if (1) # define STMT_END else (void)0 # else # define STMT_START do # define STMT_END while (0) # endif #endif #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif #ifndef DEFSV_set # define DEFSV_set(sv) (DEFSV = (sv)) #endif /* Older perls (<=5.003) lack AvFILLp */ #ifndef AvFILLp # define AvFILLp AvFILL #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif /* Hint: gv_stashpvn * This function's backport doesn't support the length parameter, but * rather ignores it. Portability can only be ensured if the length * parameter is used for speed reasons, but the length can always be * correctly computed from the string argument. */ #ifndef gv_stashpvn # define gv_stashpvn(str,len,create) gv_stashpv(str,create) #endif /* Replace: 1 */ #ifndef get_cv # define get_cv perl_get_cv #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef get_av # define get_av perl_get_av #endif #ifndef get_hv # define get_hv perl_get_hv #endif /* Replace: 0 */ #ifndef dUNDERBAR # define dUNDERBAR dNOOP #endif #ifndef UNDERBAR # define UNDERBAR DEFSV #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif #ifndef dXSTARG # define dXSTARG SV * targ = sv_newmortal() #endif #ifndef dAXMARK # define dAXMARK I32 ax = POPMARK; \ register SV ** const mark = PL_stack_base + ax++ #endif #ifndef XSprePUSH # define XSprePUSH (sp = PL_stack_base + ax - 1) #endif #if (PERL_BCDVERSION < 0x5005000) # undef XSRETURN # define XSRETURN(off) \ STMT_START { \ PL_stack_sp = PL_stack_base + ax + ((off) - 1); \ return; \ } STMT_END #endif #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif #ifndef SVfARG # define SVfARG(p) ((void*)(p)) #endif #ifndef PERL_ABS # define PERL_ABS(x) ((x) < 0 ? -(x) : (x)) #endif #ifndef dVAR # define dVAR dNOOP #endif #ifndef SVf # define SVf "_" #endif #ifndef UTF8_MAXBYTES # define UTF8_MAXBYTES UTF8_MAXLEN #endif #ifndef CPERLscope # define CPERLscope(x) x #endif #ifndef PERL_HASH # define PERL_HASH(hash,str,len) \ STMT_START { \ const char *s_PeRlHaSh = str; \ I32 i_PeRlHaSh = len; \ U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ (hash) = hash_PeRlHaSh; \ } STMT_END #endif #ifndef PERLIO_FUNCS_DECL # ifdef PERLIO_FUNCS_CONST # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs) # else # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (funcs) # endif #endif /* provide these typedefs for older perls */ #if (PERL_BCDVERSION < 0x5009003) # ifdef ARGSproto typedef OP* (CPERLscope(*Perl_ppaddr_t))(ARGSproto); # else typedef OP* (CPERLscope(*Perl_ppaddr_t))(pTHX); # endif typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #endif #ifndef isPSXSPC # define isPSXSPC(c) (isSPACE(c) || (c) == '\v') #endif #ifndef isBLANK # define isBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef EBCDIC #ifndef isALNUMC # define isALNUMC(c) isalnum(c) #endif #ifndef isASCII # define isASCII(c) isascii(c) #endif #ifndef isCNTRL # define isCNTRL(c) iscntrl(c) #endif #ifndef isGRAPH # define isGRAPH(c) isgraph(c) #endif #ifndef isPRINT # define isPRINT(c) isprint(c) #endif #ifndef isPUNCT # define isPUNCT(c) ispunct(c) #endif #ifndef isXDIGIT # define isXDIGIT(c) isxdigit(c) #endif #else # if (PERL_BCDVERSION < 0x5010000) /* Hint: isPRINT * The implementation in older perl versions includes all of the * isSPACE() characters, which is wrong. The version provided by * Devel::PPPort always overrides a present buggy version. */ # undef isPRINT # endif #ifndef isALNUMC # define isALNUMC(c) (isALPHA(c) || isDIGIT(c)) #endif #ifndef isASCII # define isASCII(c) ((U8) (c) <= 127) #endif #ifndef isCNTRL # define isCNTRL(c) ((U8) (c) < ' ' || (c) == 127) #endif #ifndef isGRAPH # define isGRAPH(c) (isALNUM(c) || isPUNCT(c)) #endif #ifndef isPRINT # define isPRINT(c) (((c) >= 32 && (c) < 127)) #endif #ifndef isPUNCT # define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126)) #endif #ifndef isXDIGIT # define isXDIGIT(c) (isDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) #endif #endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG #else # define D_PPP_PERL_SIGNALS_INIT 0 #endif #if defined(NEED_PL_signals) static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #elif defined(NEED_PL_signals_GLOBAL) U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #else extern U32 DPPP_(my_PL_signals); #endif #define PL_signals DPPP_(my_PL_signals) #endif /* Hint: PL_ppaddr * Calling an op via PL_ppaddr requires passing a context argument * for threaded builds. Since the context argument is different for * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will * automatically be defined as the correct argument. */ #if (PERL_BCDVERSION <= 0x5005005) /* Replace: 1 */ # define PL_ppaddr ppaddr # define PL_no_modify no_modify /* Replace: 0 */ #endif #if (PERL_BCDVERSION <= 0x5004005) /* Replace: 1 */ # define PL_DBsignal DBsignal # define PL_DBsingle DBsingle # define PL_DBsub DBsub # define PL_DBtrace DBtrace # define PL_Sv Sv # define PL_bufend bufend # define PL_bufptr bufptr # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_debstash debstash # define PL_defgv defgv # define PL_diehook diehook # define PL_dirty dirty # define PL_dowarn dowarn # define PL_errgv errgv # define PL_error_count error_count # define PL_expect expect # define PL_hexdigit hexdigit # define PL_hints hints # define PL_in_my in_my # define PL_laststatval laststatval # define PL_lex_state lex_state # define PL_lex_stuff lex_stuff # define PL_linestr linestr # define PL_na na # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfp rsfp # define PL_stack_base stack_base # define PL_stack_sp stack_sp # define PL_statcache statcache # define PL_stdingv stdingv # define PL_sv_arenaroot sv_arenaroot # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes # define PL_tainted tainted # define PL_tainting tainting # define PL_tokenbuf tokenbuf /* Replace: 0 */ #endif /* Warning: PL_parser * For perl versions earlier than 5.9.5, this is an always * non-NULL dummy. Also, it cannot be dereferenced. Don't * use it if you can avoid is and unless you absolutely know * what you're doing. * If you always check that PL_parser is non-NULL, you can * define DPPP_PL_parser_NO_DUMMY to avoid the creation of * a dummy parser structure. */ #if (PERL_BCDVERSION >= 0x5009005) # ifdef DPPP_PL_parser_NO_DUMMY # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (croak("panic: PL_parser == NULL in %s:%d", \ __FILE__, __LINE__), (yy_parser *) NULL))->var) # else # ifdef DPPP_PL_parser_NO_DUMMY_WARNING # define D_PPP_parser_dummy_warning(var) # else # define D_PPP_parser_dummy_warning(var) \ warn("warning: dummy PL_" #var " used in %s:%d", __FILE__, __LINE__), # endif # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (D_PPP_parser_dummy_warning(var) &DPPP_(dummy_PL_parser)))->var) #if defined(NEED_PL_parser) static yy_parser DPPP_(dummy_PL_parser); #elif defined(NEED_PL_parser_GLOBAL) yy_parser DPPP_(dummy_PL_parser); #else extern yy_parser DPPP_(dummy_PL_parser); #endif # endif /* PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf depends on PL_parser */ /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf * Do not use this variable unless you know exactly what you're * doint. It is internal to the perl parser and may change or even * be removed in the future. As of perl 5.9.5, you have to check * for (PL_parser != NULL) for this variable to have any effect. * An always non-NULL PL_parser dummy is provided for earlier * perl versions. * If PL_parser is NULL when you try to access this variable, a * dummy is being accessed instead and a warning is issued unless * you define DPPP_PL_parser_NO_DUMMY_WARNING. * If DPPP_PL_parser_NO_DUMMY is defined, the code trying to access * this variable will croak with a panic message. */ # define PL_expect D_PPP_my_PL_parser_var(expect) # define PL_copline D_PPP_my_PL_parser_var(copline) # define PL_rsfp D_PPP_my_PL_parser_var(rsfp) # define PL_rsfp_filters D_PPP_my_PL_parser_var(rsfp_filters) # define PL_linestr D_PPP_my_PL_parser_var(linestr) # define PL_bufptr D_PPP_my_PL_parser_var(bufptr) # define PL_bufend D_PPP_my_PL_parser_var(bufend) # define PL_lex_state D_PPP_my_PL_parser_var(lex_state) # define PL_lex_stuff D_PPP_my_PL_parser_var(lex_stuff) # define PL_tokenbuf D_PPP_my_PL_parser_var(tokenbuf) # define PL_in_my D_PPP_my_PL_parser_var(in_my) # define PL_in_my_stash D_PPP_my_PL_parser_var(in_my_stash) # define PL_error_count D_PPP_my_PL_parser_var(error_count) #else /* ensure that PL_parser != NULL and cannot be dereferenced */ # define PL_parser ((void *) 1) #endif #ifndef mPUSHs # define mPUSHs(s) PUSHs(sv_2mortal(s)) #endif #ifndef PUSHmortal # define PUSHmortal PUSHs(sv_newmortal()) #endif #ifndef mPUSHp # define mPUSHp(p,l) sv_setpvn(PUSHmortal, (p), (l)) #endif #ifndef mPUSHn # define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) #endif #ifndef mPUSHi # define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) #endif #ifndef mPUSHu # define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) #endif #ifndef mXPUSHs # define mXPUSHs(s) XPUSHs(sv_2mortal(s)) #endif #ifndef XPUSHmortal # define XPUSHmortal XPUSHs(sv_newmortal()) #endif #ifndef mXPUSHp # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END #endif #ifndef mXPUSHn # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END #endif #ifndef mXPUSHi # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END #endif #ifndef mXPUSHu # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END #endif /* Replace: 1 */ #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif /* Replace: 0 */ #ifndef PERL_LOADMOD_DENY # define PERL_LOADMOD_DENY 0x1 #endif #ifndef PERL_LOADMOD_NOIMPORT # define PERL_LOADMOD_NOIMPORT 0x2 #endif #ifndef PERL_LOADMOD_IMPORT_OPS # define PERL_LOADMOD_IMPORT_OPS 0x4 #endif #ifndef G_METHOD # define G_METHOD 64 # ifdef call_sv # undef call_sv # endif # if (PERL_BCDVERSION < 0x5006000) # define call_sv(sv, flags) ((flags) & G_METHOD ? perl_call_method((char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : perl_call_sv(sv, flags)) # else # define call_sv(sv, flags) ((flags) & G_METHOD ? Perl_call_method(aTHX_ (char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : Perl_call_sv(aTHX_ sv, flags)) # endif #endif /* Replace perl_eval_pv with eval_pv */ #ifndef eval_pv #if defined(NEED_eval_pv) static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); static #else extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); #endif #ifdef eval_pv # undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error) { dSP; SV* sv = newSVpv(p, 0); PUSHMARK(sp); eval_sv(sv, G_SCALAR); SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; if (croak_on_error && SvTRUE(GvSV(errgv))) croak(SvPVx(GvSV(errgv), na)); return sv; } #endif #endif #ifndef vload_module #if defined(NEED_vload_module) static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); static #else extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); #endif #ifdef vload_module # undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { dTHR; dVAR; OP *veop, *imop; OP * const modname = newSVOP(OP_CONST, 0, name); /* 5.005 has a somewhat hacky force_normal that doesn't croak on SvREADONLY() if PL_compling is true. Current perls take care in ck_require() to correctly turn off SvREADONLY before calling force_normal_flags(). This seems a better fix than fudging PL_compling */ SvREADONLY_off(((SVOP*)modname)->op_sv); modname->op_private |= OPpCONST_BARE; if (ver) { veop = newSVOP(OP_CONST, 0, ver); } else veop = NULL; if (flags & PERL_LOADMOD_NOIMPORT) { imop = sawparens(newNULLLIST()); } else if (flags & PERL_LOADMOD_IMPORT_OPS) { imop = va_arg(*args, OP*); } else { SV *sv; imop = NULL; sv = va_arg(*args, SV*); while (sv) { imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv)); sv = va_arg(*args, SV*); } } { const line_t ocopline = PL_copline; COP * const ocurcop = PL_curcop; const int oexpect = PL_expect; #if (PERL_BCDVERSION >= 0x5004000) utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0), veop, modname, imop); #else utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(), modname, imop); #endif PL_expect = oexpect; PL_copline = ocopline; PL_curcop = ocurcop; } } #endif #endif #ifndef load_module #if defined(NEED_load_module) static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); static #else extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); #endif #ifdef load_module # undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { va_list args; va_start(args, ver); vload_module(flags, name, ver, &args); va_end(args); } #endif #endif #ifndef newRV_inc # define newRV_inc(sv) newRV(sv) /* Replace */ #endif #ifndef newRV_noinc #if defined(NEED_newRV_noinc) static SV * DPPP_(my_newRV_noinc)(SV *sv); static #else extern SV * DPPP_(my_newRV_noinc)(SV *sv); #endif #ifdef newRV_noinc # undef newRV_noinc #endif #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) #define Perl_newRV_noinc DPPP_(my_newRV_noinc) #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) SV * DPPP_(my_newRV_noinc)(SV *sv) { SV *rv = (SV *)newRV(sv); SvREFCNT_dec(sv); return rv; } #endif #endif /* Hint: newCONSTSUB * Returns a CV* as of perl-5.7.1. This return value is not supported * by Devel::PPPort. */ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005) #if defined(NEED_newCONSTSUB) static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); static #else extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); #endif #ifdef newCONSTSUB # undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) /* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ #define D_PPP_PL_copline PL_copline void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) { U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = D_PPP_PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; newSUB( #if (PERL_BCDVERSION < 0x5003022) start_subparse(), #elif (PERL_BCDVERSION == 0x5003022) start_subparse(0), #else /* 5.003_23 onwards */ start_subparse(FALSE, 0), #endif newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } #endif #endif /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) #ifndef START_MY_CXT /* This must appear in all extensions that define a my_cxt_t structure, * 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. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE #define MY_CXT_CLONE NOOP #endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # else # if IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # endif # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) && (PERL_BCDVERSION != 0x5006000) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef SvREFCNT_inc # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (SvREFCNT(_sv))++; \ _sv; \ }) # else # define SvREFCNT_inc(sv) \ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL) # endif #endif #ifndef SvREFCNT_inc_simple # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_simple(sv) \ ({ \ if (sv) \ (SvREFCNT(sv))++; \ (SV *)(sv); \ }) # else # define SvREFCNT_inc_simple(sv) \ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL) # endif #endif #ifndef SvREFCNT_inc_NN # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_NN(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ SvREFCNT(_sv)++; \ _sv; \ }) # else # define SvREFCNT_inc_NN(sv) \ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv) # endif #endif #ifndef SvREFCNT_inc_void # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_void(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (void)(SvREFCNT(_sv)++); \ }) # else # define SvREFCNT_inc_void(sv) \ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0) # endif #endif #ifndef SvREFCNT_inc_simple_void # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END #endif #ifndef SvREFCNT_inc_simple_NN # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv)) #endif #ifndef SvREFCNT_inc_void_NN # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef newSV_type #if defined(NEED_newSV_type) static SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); static #else extern SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); #endif #ifdef newSV_type # undef newSV_type #endif #define newSV_type(a) DPPP_(my_newSV_type)(aTHX_ a) #define Perl_newSV_type DPPP_(my_newSV_type) #if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) SV* DPPP_(my_newSV_type)(pTHX_ svtype const t) { SV* const sv = newSV(0); sv_upgrade(sv, t); return sv; } #endif #endif #if (PERL_BCDVERSION < 0x5006000) # define D_PPP_CONSTPV_ARG(x) ((char *) (x)) #else # define D_PPP_CONSTPV_ARG(x) (x) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((data) \ ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \ : newSV(0)) #endif #ifndef newSVpvn_utf8 # define newSVpvn_utf8(s, len, u) newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) #endif #ifndef SVf_UTF8 # define SVf_UTF8 0 #endif #ifndef newSVpvn_flags #if defined(NEED_newSVpvn_flags) static SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); static #else extern SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); #endif #ifdef newSVpvn_flags # undef newSVpvn_flags #endif #define newSVpvn_flags(a,b,c) DPPP_(my_newSVpvn_flags)(aTHX_ a,b,c) #define Perl_newSVpvn_flags DPPP_(my_newSVpvn_flags) #if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags) { SV *sv = newSVpvn(D_PPP_CONSTPV_ARG(s), len); SvFLAGS(sv) |= (flags & SVf_UTF8); return (flags & SVs_TEMP) ? sv_2mortal(sv) : sv; } #endif #endif /* Backwards compatibility stuff... :-( */ #if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen) # define NEED_sv_2pv_flags #endif #if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL) # define NEED_sv_2pv_flags_GLOBAL #endif /* Hint: sv_2pv_nolen * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen(). */ #ifndef sv_2pv_nolen # define sv_2pv_nolen(sv) SvPV_nolen(sv) #endif #ifdef SvPVbyte /* Hint: SvPVbyte * Does not work in perl-5.6.1, ppport.h implements a version * borrowed from perl-5.7.3. */ #if (PERL_BCDVERSION < 0x5007000) #if defined(NEED_sv_2pvbyte) static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); static #else extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); #endif #ifdef sv_2pvbyte # undef sv_2pvbyte #endif #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } #endif /* Hint: sv_2pvbyte * Use the SvPVbyte() macro instead of sv_2pvbyte(). */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp)) #endif #else # define SvPVbyte SvPV # define sv_2pvbyte sv_2pv #endif #ifndef sv_2pvbyte_nolen # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv) #endif /* Hint: sv_pvn * Always use the SvPV() macro instead of sv_pvn(). */ /* Hint: sv_pvn_force * Always use the SvPV_force() macro instead of sv_pvn_force(). */ /* If these are undefined, they're not handled by the core anyway */ #ifndef SV_IMMEDIATE_UNREF # define SV_IMMEDIATE_UNREF 0 #endif #ifndef SV_GMAGIC # define SV_GMAGIC 0 #endif #ifndef SV_COW_DROP_PV # define SV_COW_DROP_PV 0 #endif #ifndef SV_UTF8_NO_ENCODING # define SV_UTF8_NO_ENCODING 0 #endif #ifndef SV_NOSTEAL # define SV_NOSTEAL 0 #endif #ifndef SV_CONST_RETURN # define SV_CONST_RETURN 0 #endif #ifndef SV_MUTABLE_RETURN # define SV_MUTABLE_RETURN 0 #endif #ifndef SV_SMAGIC # define SV_SMAGIC 0 #endif #ifndef SV_HAS_TRAILING_NUL # define SV_HAS_TRAILING_NUL 0 #endif #ifndef SV_COW_SHARED_HASH_KEYS # define SV_COW_SHARED_HASH_KEYS 0 #endif #if (PERL_BCDVERSION < 0x5007002) #if defined(NEED_sv_2pv_flags) static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_2pv_flags # undef sv_2pv_flags #endif #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_2pv(sv, lp ? lp : &n_a); } #endif #if defined(NEED_sv_pvn_force_flags) static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_pvn_force_flags # undef sv_pvn_force_flags #endif #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_pvn_force(sv, lp ? lp : &n_a); } #endif #endif #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) # define DPPP_SVPV_NOLEN_LP_ARG &PL_na #else # define DPPP_SVPV_NOLEN_LP_ARG 0 #endif #ifndef SvPV_const # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_mutable # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_flags # define SvPV_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags)) #endif #ifndef SvPV_flags_const # define SvPV_flags_const(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \ (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_const_nolen # define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ (const char*) sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable # define SvPV_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_force # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nolen # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC) #endif #ifndef SvPV_force_mutable # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nomg # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0) #endif #ifndef SvPV_force_nomg_nolen # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0) #endif #ifndef SvPV_force_flags # define SvPV_force_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags)) #endif #ifndef SvPV_force_flags_nolen # define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? SvPVX(sv) : sv_pvn_force_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags)) #endif #ifndef SvPV_force_flags_mutable # define SvPV_force_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \ : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const # define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) #endif #ifndef SvPV_nomg # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) #endif #ifndef SvPV_nomg_const # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0) #endif #ifndef SvPV_nomg_const_nolen # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0) #endif #ifndef SvPV_renew # define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ SvPV_set((sv), (char *) saferealloc( \ (Malloc_t)SvPVX(sv), (MEM_SIZE)((n)))); \ } STMT_END #endif #ifndef SvMAGIC_set # define SvMAGIC_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5009003) #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv))) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) (0 + SvPVX(sv)) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END #endif #else #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ ((sv)->sv_u.svu_rv = (val)); } STMT_END #endif #endif #ifndef SvSTASH_set # define SvSTASH_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5004000) #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END #endif #else #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf) #if defined(NEED_vnewSVpvf) static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); static #else extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); #endif #ifdef vnewSVpvf # undef vnewSVpvf #endif #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) { register SV *sv = newSV(0); sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); return sv; } #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf) # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf) # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) static void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */ #ifndef sv_catpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext # else # define sv_catpvf_mg Perl_sv_catpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg) # define sv_vcatpvf_mg(sv, pat, args) \ STMT_START { \ sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) static void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */ #ifndef sv_setpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext # else # define sv_setpvf_mg Perl_sv_setpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg) # define sv_vsetpvf_mg(sv, pat, args) \ STMT_START { \ sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif /* Hint: newSVpvn_share * The SVs created by this function only mimic the behaviour of * shared PVs without really being shared. Only use if you know * what you're doing. */ #ifndef newSVpvn_share #if defined(NEED_newSVpvn_share) static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); #endif #ifdef newSVpvn_share # undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) { SV *sv; if (len < 0) len = -len; if (!hash) PERL_HASH(hash, (char*) src, len); sv = newSVpvn((char *) src, len); sv_upgrade(sv, SVt_PVIV); SvIVX(sv) = hash; SvREADONLY_on(sv); SvPOK_on(sv); return sv; } #endif #endif #ifndef SvSHARED_HASH # define SvSHARED_HASH(sv) (0 + SvUVX(sv)) #endif #ifndef HvNAME_get # define HvNAME_get(hv) HvNAME(hv) #endif #ifndef HvNAMELEN_get # define HvNAMELEN_get(hv) (HvNAME_get(hv) ? (I32)strlen(HvNAME_get(hv)) : 0) #endif #ifndef GvSVn # define GvSVn(gv) GvSV(gv) #endif #ifndef isGV_with_GP # define isGV_with_GP(gv) isGV(gv) #endif #ifndef gv_fetchpvn_flags # define gv_fetchpvn_flags(name, len, flags, svt) gv_fetchpv(name, flags, svt) #endif #ifndef gv_fetchsv # define gv_fetchsv(name, flags, svt) gv_fetchpv(SvPV_nolen_const(name), flags, svt) #endif #ifndef get_cvn_flags # define get_cvn_flags(name, namelen, flags) get_cv(name, flags) #endif #ifndef WARN_ALL # define WARN_ALL 0 #endif #ifndef WARN_CLOSURE # define WARN_CLOSURE 1 #endif #ifndef WARN_DEPRECATED # define WARN_DEPRECATED 2 #endif #ifndef WARN_EXITING # define WARN_EXITING 3 #endif #ifndef WARN_GLOB # define WARN_GLOB 4 #endif #ifndef WARN_IO # define WARN_IO 5 #endif #ifndef WARN_CLOSED # define WARN_CLOSED 6 #endif #ifndef WARN_EXEC # define WARN_EXEC 7 #endif #ifndef WARN_LAYER # define WARN_LAYER 8 #endif #ifndef WARN_NEWLINE # define WARN_NEWLINE 9 #endif #ifndef WARN_PIPE # define WARN_PIPE 10 #endif #ifndef WARN_UNOPENED # define WARN_UNOPENED 11 #endif #ifndef WARN_MISC # define WARN_MISC 12 #endif #ifndef WARN_NUMERIC # define WARN_NUMERIC 13 #endif #ifndef WARN_ONCE # define WARN_ONCE 14 #endif #ifndef WARN_OVERFLOW # define WARN_OVERFLOW 15 #endif #ifndef WARN_PACK # define WARN_PACK 16 #endif #ifndef WARN_PORTABLE # define WARN_PORTABLE 17 #endif #ifndef WARN_RECURSION # define WARN_RECURSION 18 #endif #ifndef WARN_REDEFINE # define WARN_REDEFINE 19 #endif #ifndef WARN_REGEXP # define WARN_REGEXP 20 #endif #ifndef WARN_SEVERE # define WARN_SEVERE 21 #endif #ifndef WARN_DEBUGGING # define WARN_DEBUGGING 22 #endif #ifndef WARN_INPLACE # define WARN_INPLACE 23 #endif #ifndef WARN_INTERNAL # define WARN_INTERNAL 24 #endif #ifndef WARN_MALLOC # define WARN_MALLOC 25 #endif #ifndef WARN_SIGNAL # define WARN_SIGNAL 26 #endif #ifndef WARN_SUBSTR # define WARN_SUBSTR 27 #endif #ifndef WARN_SYNTAX # define WARN_SYNTAX 28 #endif #ifndef WARN_AMBIGUOUS # define WARN_AMBIGUOUS 29 #endif #ifndef WARN_BAREWORD # define WARN_BAREWORD 30 #endif #ifndef WARN_DIGIT # define WARN_DIGIT 31 #endif #ifndef WARN_PARENTHESIS # define WARN_PARENTHESIS 32 #endif #ifndef WARN_PRECEDENCE # define WARN_PRECEDENCE 33 #endif #ifndef WARN_PRINTF # define WARN_PRINTF 34 #endif #ifndef WARN_PROTOTYPE # define WARN_PROTOTYPE 35 #endif #ifndef WARN_QW # define WARN_QW 36 #endif #ifndef WARN_RESERVED # define WARN_RESERVED 37 #endif #ifndef WARN_SEMICOLON # define WARN_SEMICOLON 38 #endif #ifndef WARN_TAINT # define WARN_TAINT 39 #endif #ifndef WARN_THREADS # define WARN_THREADS 40 #endif #ifndef WARN_UNINITIALIZED # define WARN_UNINITIALIZED 41 #endif #ifndef WARN_UNPACK # define WARN_UNPACK 42 #endif #ifndef WARN_UNTIE # define WARN_UNTIE 43 #endif #ifndef WARN_UTF8 # define WARN_UTF8 44 #endif #ifndef WARN_VOID # define WARN_VOID 45 #endif #ifndef WARN_ASSERTIONS # define WARN_ASSERTIONS 46 #endif #ifndef packWARN # define packWARN(a) (a) #endif #ifndef ckWARN # ifdef G_WARN_ON # define ckWARN(a) (PL_dowarn & G_WARN_ON) # else # define ckWARN(a) PL_dowarn # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) #if defined(NEED_warner) static void DPPP_(my_warner)(U32 err, const char *pat, ...); static #else extern void DPPP_(my_warner)(U32 err, const char *pat, ...); #endif #define Perl_warner DPPP_(my_warner) #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) void DPPP_(my_warner)(U32 err, const char *pat, ...) { SV *sv; va_list args; PERL_UNUSED_ARG(err); va_start(args, pat); sv = vnewSVpvf(pat, &args); va_end(args); sv_2mortal(sv); warn("%s", SvPV_nolen(sv)); } #define warner Perl_warner #define Perl_warner_nocontext Perl_warner #endif #endif /* concatenating with "" ensures that only literal strings are accepted as argument * note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros */ #ifndef STR_WITH_LEN # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1) #endif #ifndef newSVpvs # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1) #endif #ifndef newSVpvs_flags # define newSVpvs_flags(str, flags) newSVpvn_flags(str "", sizeof(str) - 1, flags) #endif #ifndef newSVpvs_share # define newSVpvs_share(str) newSVpvn_share(str "", sizeof(str) - 1, 0) #endif #ifndef sv_catpvs # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1) #endif #ifndef sv_setpvs # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1) #endif #ifndef hv_fetchs # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval) #endif #ifndef hv_stores # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0) #endif #ifndef gv_fetchpvs # define gv_fetchpvs(name, flags, svt) gv_fetchpvn_flags(name "", sizeof(name) - 1, flags, svt) #endif #ifndef gv_stashpvs # define gv_stashpvs(name, flags) gv_stashpvn(name "", sizeof(name) - 1, flags) #endif #ifndef get_cvs # define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags) #endif #ifndef SvGETMAGIC # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #endif #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #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 #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #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 #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif /* That's the best we can do... */ #ifndef sv_catpvn_nomg # define sv_catpvn_nomg sv_catpvn #endif #ifndef sv_catsv_nomg # define sv_catsv_nomg sv_catsv #endif #ifndef sv_setsv_nomg # define sv_setsv_nomg sv_setsv #endif #ifndef sv_pvn_nomg # define sv_pvn_nomg sv_pvn #endif #ifndef SvIV_nomg # define SvIV_nomg SvIV #endif #ifndef SvUV_nomg # define SvUV_nomg SvUV #endif #ifndef sv_catpv_mg # define sv_catpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catpvn_mg # define sv_catpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catsv_mg # define sv_catsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_catsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setiv_mg # define sv_setiv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setiv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setnv_mg # define sv_setnv_mg(sv, num) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setnv(TeMpSv,num); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpv_mg # define sv_setpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpvn_mg # define sv_setpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setsv_mg # define sv_setsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_setsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setuv_mg # define sv_setuv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setuv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_usepvn_mg # define sv_usepvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_usepvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef SvVSTRING_mg # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL) #endif /* Hint: sv_magic_portable * This is a compatibility function that is only available with * Devel::PPPort. It is NOT in the perl core. * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when * it is being passed a name pointer with namlen == 0. In that * case, perl 5.8.0 and later store the pointer, not a copy of it. * The compatibility can be provided back to perl 5.004. With * earlier versions, the code will not compile. */ #if (PERL_BCDVERSION < 0x5004000) /* code that uses sv_magic_portable will not compile */ #elif (PERL_BCDVERSION < 0x5008000) # define sv_magic_portable(sv, obj, how, name, namlen) \ STMT_START { \ SV *SvMp_sv = (sv); \ char *SvMp_name = (char *) (name); \ I32 SvMp_namlen = (namlen); \ if (SvMp_name && SvMp_namlen == 0) \ { \ MAGIC *mg; \ sv_magic(SvMp_sv, obj, how, 0, 0); \ mg = SvMAGIC(SvMp_sv); \ mg->mg_len = -42; /* XXX: this is the tricky part */ \ mg->mg_ptr = SvMp_name; \ } \ else \ { \ sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \ } \ } STMT_END #else # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e) #endif #ifdef USE_ITHREADS #ifndef CopFILE # define CopFILE(c) ((c)->cop_file) #endif #ifndef CopFILEGV # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) ((c)->cop_stashpv) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) #endif #ifndef CopSTASH # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ || (CopSTASHPV(c) && HvNAME(hv) \ && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else #ifndef CopFILEGV # define CopFILEGV(c) ((c)->cop_filegv) #endif #ifndef CopFILEGV_set # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) #endif #ifndef CopFILE # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) #endif #ifndef CopSTASH # define CopSTASH(c) ((c)->cop_stash) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) #endif #endif /* USE_ITHREADS */ #ifndef IN_PERL_COMPILETIME # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IN_LOCALE # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 #endif #ifndef IS_NUMBER_GREATER_THAN_UV_MAX # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 #endif #ifndef IS_NUMBER_NOT_INT # define IS_NUMBER_NOT_INT 0x04 #endif #ifndef IS_NUMBER_NEG # define IS_NUMBER_NEG 0x08 #endif #ifndef IS_NUMBER_INFINITY # define IS_NUMBER_INFINITY 0x10 #endif #ifndef IS_NUMBER_NAN # define IS_NUMBER_NAN 0x20 #endif #ifndef GROK_NUMERIC_RADIX # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send) #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #ifndef grok_numeric_radix #if defined(NEED_grok_numeric_radix) static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); #endif #ifdef grok_numeric_radix # undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #ifdef PL_numeric_radix_sv if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* older perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include dTHR; /* needed for older threaded perls */ struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif #endif #ifndef grok_number #if defined(NEED_grok_number) static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif #ifdef grok_number # undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif #endif /* * The grok_* routines have been modified to use warn() instead of * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit, * which is why the stack variable has been renamed to 'xdigit'. */ #ifndef grok_bin #if defined(NEED_grok_bin) static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_bin # undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_2 = UV_MAX / 2; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading b or 0b. for compatibility silently suffer "b" and "0b" as valid binary numbers. */ if (len >= 1) { if (s[0] == 'b') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'b') { s+=2; len-=2; } } } for (; len-- && *s; s++) { char bit = *s; if (bit == '0' || bit == '1') { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_bin. */ redo: if (!overflowed) { if (value <= max_div_2) { value = (value << 1) | (bit - '0'); continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in binary number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_hex #if defined(NEED_grok_hex) static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_hex # undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_16 = UV_MAX / 16; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; const char *xdigit; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading x or 0x. for compatibility silently suffer "x" and "0x" as valid hex numbers. */ if (len >= 1) { if (s[0] == 'x') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'x') { s+=2; len-=2; } } } for (; len-- && *s; s++) { xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_hex. */ redo: if (!overflowed) { if (value <= max_div_16) { value = (value << 4) | ((xdigit - PL_hexdigit) & 15); continue; } warn("Integer overflow in hexadecimal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] && (xdigit = strchr((char *) PL_hexdigit, s[1]))) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_oct #if defined(NEED_grok_oct) static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_oct # undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_8 = UV_MAX / 8; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; for (; len-- && *s; s++) { /* gcc 2.95 optimiser not smart enough to figure that this subtraction out front allows slicker code. */ int digit = *s - '0'; if (digit >= 0 && digit <= 7) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. */ redo: if (!overflowed) { if (value <= max_div_8) { value = (value << 3) | digit; continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in octal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) { --len; ++s; goto redo; } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ if (digit == 8 || digit == 9) { if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal octal digit '%c' ignored", *s); } break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #if !defined(my_snprintf) #if defined(NEED_my_snprintf) static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } #endif #endif #if !defined(my_sprintf) #if defined(NEED_my_sprintf) static int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); static #else extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); #endif #define my_sprintf DPPP_(my_my_sprintf) #define Perl_my_sprintf DPPP_(my_my_sprintf) #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) int DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) { va_list args; va_start(args, pat); vsprintf(buffer, pat, args); va_end(args); return strlen(buffer); } #endif #endif #ifdef NO_XSLOCKS # ifdef dJMPENV # define dXCPT dJMPENV; int rEtV = 0 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) # define XCPT_TRY_END JMPENV_POP; # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW JMPENV_JUMP(rEtV) # else # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0) # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf); # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW Siglongjmp(top_env, rEtV) # endif #endif #if !defined(my_strlcat) #if defined(NEED_my_strlcat) static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { Size_t used, length, copy; used = strlen(dst); length = strlen(src); if (size > 0 && used < size - 1) { copy = (length >= size - used) ? size - used - 1 : length; memcpy(dst + used, src, copy); dst[used + copy] = '\0'; } return used + length; } #endif #endif #if !defined(my_strlcpy) #if defined(NEED_my_strlcpy) static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { Size_t length, copy; length = strlen(src); if (size > 0) { copy = (length >= size) ? size - 1 : length; memcpy(dst, src, copy); dst[copy] = '\0'; } return length; } #endif #endif #ifndef PERL_PV_ESCAPE_QUOTE # define PERL_PV_ESCAPE_QUOTE 0x0001 #endif #ifndef PERL_PV_PRETTY_QUOTE # define PERL_PV_PRETTY_QUOTE PERL_PV_ESCAPE_QUOTE #endif #ifndef PERL_PV_PRETTY_ELLIPSES # define PERL_PV_PRETTY_ELLIPSES 0x0002 #endif #ifndef PERL_PV_PRETTY_LTGT # define PERL_PV_PRETTY_LTGT 0x0004 #endif #ifndef PERL_PV_ESCAPE_FIRSTCHAR # define PERL_PV_ESCAPE_FIRSTCHAR 0x0008 #endif #ifndef PERL_PV_ESCAPE_UNI # define PERL_PV_ESCAPE_UNI 0x0100 #endif #ifndef PERL_PV_ESCAPE_UNI_DETECT # define PERL_PV_ESCAPE_UNI_DETECT 0x0200 #endif #ifndef PERL_PV_ESCAPE_ALL # define PERL_PV_ESCAPE_ALL 0x1000 #endif #ifndef PERL_PV_ESCAPE_NOBACKSLASH # define PERL_PV_ESCAPE_NOBACKSLASH 0x2000 #endif #ifndef PERL_PV_ESCAPE_NOCLEAR # define PERL_PV_ESCAPE_NOCLEAR 0x4000 #endif #ifndef PERL_PV_ESCAPE_RE # define PERL_PV_ESCAPE_RE 0x8000 #endif #ifndef PERL_PV_PRETTY_NOCLEAR # define PERL_PV_PRETTY_NOCLEAR PERL_PV_ESCAPE_NOCLEAR #endif #ifndef PERL_PV_PRETTY_DUMP # define PERL_PV_PRETTY_DUMP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_QUOTE #endif #ifndef PERL_PV_PRETTY_REGPROP # define PERL_PV_PRETTY_REGPROP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_LTGT|PERL_PV_ESCAPE_RE #endif /* Hint: pv_escape * Note that unicode functionality is only backported to * those perl versions that support it. For older perl * versions, the implementation will fall back to bytes. */ #ifndef pv_escape #if defined(NEED_pv_escape) static char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); static #else extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); #endif #ifdef pv_escape # undef pv_escape #endif #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) #define Perl_pv_escape DPPP_(my_pv_escape) #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) char * DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags) { const char esc = flags & PERL_PV_ESCAPE_RE ? '%' : '\\'; const char dq = flags & PERL_PV_ESCAPE_QUOTE ? '"' : esc; char octbuf[32] = "%123456789ABCDF"; STRLEN wrote = 0; STRLEN chsize = 0; STRLEN readsize = 1; #if defined(is_utf8_string) && defined(utf8_to_uvchr) bool isuni = flags & PERL_PV_ESCAPE_UNI ? 1 : 0; #endif const char *pv = str; const char * const end = pv + count; octbuf[0] = esc; if (!(flags & PERL_PV_ESCAPE_NOCLEAR)) sv_setpvs(dsv, ""); #if defined(is_utf8_string) && defined(utf8_to_uvchr) if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) isuni = 1; #endif for (; pv < end && (!max || wrote < max) ; pv += readsize) { const UV u = #if defined(is_utf8_string) && defined(utf8_to_uvchr) isuni ? utf8_to_uvchr((U8*)pv, &readsize) : #endif (U8)*pv; const U8 c = (U8)u & 0xFF; if (u > 255 || (flags & PERL_PV_ESCAPE_ALL)) { if (flags & PERL_PV_ESCAPE_FIRSTCHAR) chsize = my_snprintf(octbuf, sizeof octbuf, "%"UVxf, u); else chsize = my_snprintf(octbuf, sizeof octbuf, "%cx{%"UVxf"}", esc, u); } else if (flags & PERL_PV_ESCAPE_NOBACKSLASH) { chsize = 1; } else { if (c == dq || c == esc || !isPRINT(c)) { chsize = 2; switch (c) { case '\\' : /* fallthrough */ case '%' : if (c == esc) octbuf[1] = esc; else chsize = 1; break; case '\v' : octbuf[1] = 'v'; break; case '\t' : octbuf[1] = 't'; break; case '\r' : octbuf[1] = 'r'; break; case '\n' : octbuf[1] = 'n'; break; case '\f' : octbuf[1] = 'f'; break; case '"' : if (dq == '"') octbuf[1] = '"'; else chsize = 1; break; default: chsize = my_snprintf(octbuf, sizeof octbuf, pv < end && isDIGIT((U8)*(pv+readsize)) ? "%c%03o" : "%c%o", esc, c); } } else { chsize = 1; } } if (max && wrote + chsize > max) { break; } else if (chsize > 1) { sv_catpvn(dsv, octbuf, chsize); wrote += chsize; } else { char tmp[2]; my_snprintf(tmp, sizeof tmp, "%c", c); sv_catpvn(dsv, tmp, 1); wrote++; } if (flags & PERL_PV_ESCAPE_FIRSTCHAR) break; } if (escaped != NULL) *escaped= pv - str; return SvPVX(dsv); } #endif #endif #ifndef pv_pretty #if defined(NEED_pv_pretty) static char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); static #else extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); #endif #ifdef pv_pretty # undef pv_pretty #endif #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) #define Perl_pv_pretty DPPP_(my_pv_pretty) #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) char * DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags) { const U8 dq = (flags & PERL_PV_PRETTY_QUOTE) ? '"' : '%'; STRLEN escaped; if (!(flags & PERL_PV_PRETTY_NOCLEAR)) sv_setpvs(dsv, ""); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, "<"); if (start_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(start_color)); pv_escape(dsv, str, count, max, &escaped, flags | PERL_PV_ESCAPE_NOCLEAR); if (end_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(end_color)); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, ">"); if ((flags & PERL_PV_PRETTY_ELLIPSES) && escaped < count) sv_catpvs(dsv, "..."); return SvPVX(dsv); } #endif #endif #ifndef pv_display #if defined(NEED_pv_display) static char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); static #else extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); #endif #ifdef pv_display # undef pv_display #endif #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) #define Perl_pv_display DPPP_(my_pv_display) #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) char * DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) { pv_pretty(dsv, pv, cur, pvlim, NULL, NULL, PERL_PV_PRETTY_DUMP); if (len > cur && pv[cur] == '\0') sv_catpvs(dsv, "\\0"); return SvPVX(dsv); } #endif #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File ppport.h */ LMDB_File-0.13/typemap0000644000175600003110000000357512422447560013057 0ustar sogsoftTYPEMAP LMDB::Env T_PTROBJ LMDB::Txn T_PTROBJ TxnOrNull T_PTROBJ_N LMDB::Cursor T_PTROBJ #LMDB T_OPAQUE LMDB T_UV DBD T_datum DBK T_keydatum DBKC T_keydatumC MDB_cursor_op T_IV mdb_filehandle_t T_FD HV * T_HVREF_REFCOUNT_FIXED # Type to avoid warnings when a flag is undefined flags_t T_UV_N INPUT T_datum Sv2DBD($arg, $var); T_keydatum if (ISDBKINT) { SvIV_please($arg); $var.mv_data = &(((XPVIV*)SvANY($arg))->xiv_iv); $var.mv_size = sizeof(MyInt); } else $var.mv_data = SvPV($arg, $var.mv_size); T_keydatumC if (ISDBKINT) { if(SvOK($arg)) { SvIV_please($arg); $var.mv_data = &(((XPVIV*)SvANY($arg))->xiv_iv); } else $var.mv_data = (MyInt *)\"\\0\\0\\0\\0\\0\\0\\0\\0\"; $var.mv_size = sizeof(MyInt); } else if(SvOK($arg)) $var.mv_data = SvPV($arg, $var.mv_size); T_FD $var = PerlIO_fileno(IoOFP(sv_2io($arg))); T_PTROBJ_N if(!SvTRUE($arg)) { $var = ($type) NULL; } else if (SvROK($arg) && sv_derived_from($arg, \"LMDB::Txn\")) { IV tmp = SvIV((SV*)SvRV($arg)); $var = INT2PTR($type,tmp); } else Perl_croak(aTHX_ \"%s: %s is not of type %s\", ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, \"$var\", \"LMDB::Txn\"); T_UV_N $var = SvOK($arg) ? ($type)SvUV($arg) : 0; #################################################################################### OUTPUT T_datum sv_setstatic(aTHX_ aMY_CXT_ $arg, &$var, 0); T_keydatum if(ISDBKINT) { sv_setiv_mg($arg, *(MyInt *)$var.mv_data); } else { sv_setpvn_mg($arg, $var.mv_data, $var.mv_size); SvUTF8_off($arg); } T_keydatumC if(op != MDB_SET) { if(ISDBKINT) { sv_setiv_mg($arg, *(MyInt *)$var.mv_data); } else { sv_setpvn_mg($arg, $var.mv_data, $var.mv_size); SvUTF8_off($arg); } } T_HVREF_REFCOUNT_FIXED $arg = newRV_noinc((SV*)$var); LMDB_File-0.13/Changes0000644000175600003110000000553714475127466012762 0ustar sogsoftRevision history for Perl extension LMDB_File. 0.13 Sat Sep 02 2023 - Fix for hidden Perl_do_vecget in 5.38 Thanks to Niko Tyni for the patch 0.12 Wed Jan 25 2017 - Conditionally compile mdb_txn_id support. - Updated README 0.11 Tue Jan 24 2017 - Fix a leak in error path - Add support for mdb_txn_id 0.10 Fri May 20 2016 - Update for changes in MULTICALL API in 5.24 0.09 Wed Jan 27 2016 - Stole^WPort lmdb fix for my env_get_flags as a fix for older lmdbs 0.08 Tue Jan 21 2016 - Include liblmdb 0.9.70 - Adjust a test for fixed env_get_flags - Fix for non English locales at test time, thanks to SREZIC - Assorted cleanup Thanks to rouzier and yanick for its contributions 0.07 Mon Nov 3 2014 - All DB perl-implemented attributes (comparators, ReadMode, UTF8, etc.) are now keep in Env's wrapper, so preserved across transactions. - Implement raw vs UTF-8 encoded DBs. See LMDB_File->UTF8 - Revamp zero-copy read mode. Please review LMDB_File->ReadMode - Implement MDB_RESERVE flag in puts. - Include RELEASED liblmdb 0.9.14 - Uses mdb_env_copy2 and mdb_env_copyfd2 for MDB_CP_COMPACT support - Expose low-level put and get as methods of LDMB::Txn - Add missing post 0.9.10 constants 0.06 Mon Sep 15 2014 - Include liblmdb 0.9.14 - Add LMDB::Txn->open and LMDB_file->new for low level dbi handling - Complete LMDB_File->drop support. - Fix typo in ->set_maxreaders - Use proper default flags for some methods. Thanks to Ken Fredric for its testing and reports 0.05 Fri Nov 22 2013 - Depends on 0.9.10+ - Relax Perl version dependency to 5.10.0 - Avoid using freed memory at transaction end. - Add -lrt, needed in solaris - Documentation fixes Thanks to Doug Hoyte for its contributions. 0.04 Tue Oct 8 2013 - Depends on 0.9.8+ for fixed mdb_env_copy and changed mdb_dbi_flags. - Cache dbflags to avoid repeated function calls - Fix custom comparators to use global $a and $b - Add experimental LMDB_File->Flush method that commit and re-open a txn/db for continued use, proposed by Mark Zealey. - Experimental zero-copy read mode. See LDMB_File->ReadMode 0.03 Fri Aug 23 2013 - Fix MDB_INTEGERKEY handling, now works - Reimplement mdb_env_copy to avoid O_DIRECT issues in unsupported filesystems. - Fix STORE when using tie, thanks to Mark Zealey for the report. - Avoid warn "undefined" for flags. - Use proper locale when testing, should fix Alexandr Ciornii's failed tests reports. 0.02 Tue Aug 20 2013 - Fix build with non threaded Perl. - Skip a test when can't create local directory. - Use LIBS and INC if passed to Makefile.PL 0.01 Mon Aug 19 2013 - early testing release, beta? 0.00 Tue Aug 6 11:44:32 2013 - original version; created by h2xs 1.23 LMDB_File-0.13/fallback/0000755000175600003110000000000014552575256013214 5ustar sogsoftLMDB_File-0.13/fallback/const-xs.inc0000644000175600003110000000501512422331465015450 0ustar sogsoftvoid constant(sv) PREINIT: #ifdef dXSTARG dXSTARG; /* Faster if we have it. */ #else dTARGET; #endif STRLEN len; int type; IV iv; /* NV nv; Uncomment this if you need to return NVs */ const char *pv; INPUT: SV * sv; const char * s = SvPV(sv, len); PPCODE: /* Change this to constant(aTHX_ s, len, &iv, &nv); if you need to return both NVs and IVs */ type = constant(aTHX_ s, len, &iv, &pv); /* Return 1 or 2 items. First is error message, or undef if no error. Second, if present, is found value */ switch (type) { case PERL_constant_NOTFOUND: sv = sv_2mortal(newSVpvf("%s is not a valid LMDB_File macro", s)); PUSHs(sv); break; case PERL_constant_NOTDEF: sv = sv_2mortal(newSVpvf( "Your vendor has not defined LMDB_File macro %s, used", s)); PUSHs(sv); break; case PERL_constant_ISIV: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHi(iv); break; /* Uncomment this if you need to return NOs case PERL_constant_ISNO: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHs(&PL_sv_no); break; */ /* Uncomment this if you need to return NVs case PERL_constant_ISNV: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHn(nv); break; */ case PERL_constant_ISPV: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHp(pv, strlen(pv)); break; /* Uncomment this if you need to return PVNs case PERL_constant_ISPVN: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHp(pv, iv); break; */ /* Uncomment this if you need to return SVs case PERL_constant_ISSV: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHs(sv); break; */ /* Uncomment this if you need to return UNDEFs case PERL_constant_ISUNDEF: break; */ /* Uncomment this if you need to return UVs case PERL_constant_ISUV: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHu((UV)iv); break; */ /* Uncomment this if you need to return YESs case PERL_constant_ISYES: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHs(&PL_sv_yes); break; */ default: sv = sv_2mortal(newSVpvf( "Unexpected return type %d while processing LMDB_File macro %s, used", type, s)); PUSHs(sv); } LMDB_File-0.13/fallback/const-c.inc0000644000175600003110000006241212650271303015241 0ustar sogsoft#define PERL_constant_NOTFOUND 1 #define PERL_constant_NOTDEF 2 #define PERL_constant_ISIV 3 #define PERL_constant_ISNO 4 #define PERL_constant_ISNV 5 #define PERL_constant_ISPV 6 #define PERL_constant_ISPVN 7 #define PERL_constant_ISSV 8 #define PERL_constant_ISUNDEF 9 #define PERL_constant_ISUV 10 #define PERL_constant_ISYES 11 #ifndef NVTYPE typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it. */ #endif #ifndef aTHX_ #define aTHX_ /* 5.6 or later define this for threading support. */ #endif #ifndef pTHX_ #define pTHX_ /* 5.6 or later define this for threading support. */ #endif static int constant_8 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. MDB_LAST MDB_NEXT MDB_PREV */ /* Offset 4 gives the best switch position. */ switch (name[4]) { case 'L': if (memEQ(name, "MDB_LAST", 8)) { /* ^ */ *iv_return = MDB_LAST; return PERL_constant_ISIV; } break; case 'N': if (memEQ(name, "MDB_NEXT", 8)) { /* ^ */ *iv_return = MDB_NEXT; return PERL_constant_ISIV; } break; case 'P': if (memEQ(name, "MDB_PREV", 8)) { /* ^ */ *iv_return = MDB_PREV; return PERL_constant_ISIV; } break; } return PERL_constant_NOTFOUND; } static int constant_9 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. MDB_FIRST MDB_NOTLS MDB_PANIC */ /* Offset 6 gives the best switch position. */ switch (name[6]) { case 'N': if (memEQ(name, "MDB_PANIC", 9)) { /* ^ */ #ifdef MDB_PANIC *iv_return = MDB_PANIC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "MDB_FIRST", 9)) { /* ^ */ *iv_return = MDB_FIRST; return PERL_constant_ISIV; } break; case 'T': if (memEQ(name, "MDB_NOTLS", 9)) { /* ^ */ #ifdef MDB_NOTLS *iv_return = MDB_NOTLS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_10 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. MDB_APPEND MDB_CREATE MDB_NOLOCK MDB_NOSYNC MDB_RDONLY */ /* Offset 6 gives the best switch position. */ switch (name[6]) { case 'E': if (memEQ(name, "MDB_CREATE", 10)) { /* ^ */ #ifdef MDB_CREATE *iv_return = MDB_CREATE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "MDB_NOLOCK", 10)) { /* ^ */ #ifdef MDB_NOLOCK *iv_return = MDB_NOLOCK; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "MDB_RDONLY", 10)) { /* ^ */ #ifdef MDB_RDONLY *iv_return = MDB_RDONLY; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'P': if (memEQ(name, "MDB_APPEND", 10)) { /* ^ */ #ifdef MDB_APPEND *iv_return = MDB_APPEND; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "MDB_NOSYNC", 10)) { /* ^ */ #ifdef MDB_NOSYNC *iv_return = MDB_NOSYNC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_11 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LMDB_OFLAGN MDB_BAD_DBI MDB_BAD_TXN MDB_CURRENT MDB_DUPSORT MDB_INVALID MDB_RESERVE MDB_SET_KEY MDB_SUCCESS */ /* Offset 9 gives the best switch position. */ switch (name[9]) { case 'B': if (memEQ(name, "MDB_BAD_DBI", 11)) { /* ^ */ #ifdef MDB_BAD_DBI *iv_return = MDB_BAD_DBI; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'E': if (memEQ(name, "MDB_SET_KEY", 11)) { /* ^ */ *iv_return = MDB_SET_KEY; return PERL_constant_ISIV; } break; case 'G': if (memEQ(name, "LMDB_OFLAGN", 11)) { /* ^ */ #ifdef LMDB_OFLAGN *iv_return = LMDB_OFLAGN; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "MDB_INVALID", 11)) { /* ^ */ #ifdef MDB_INVALID *iv_return = MDB_INVALID; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "MDB_CURRENT", 11)) { /* ^ */ #ifdef MDB_CURRENT *iv_return = MDB_CURRENT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "MDB_DUPSORT", 11)) { /* ^ */ #ifdef MDB_DUPSORT *iv_return = MDB_DUPSORT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "MDB_SUCCESS", 11)) { /* ^ */ #ifdef MDB_SUCCESS *iv_return = MDB_SUCCESS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'V': if (memEQ(name, "MDB_RESERVE", 11)) { /* ^ */ #ifdef MDB_RESERVE *iv_return = MDB_RESERVE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'X': if (memEQ(name, "MDB_BAD_TXN", 11)) { /* ^ */ #ifdef MDB_BAD_TXN *iv_return = MDB_BAD_TXN; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_12 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. MDB_DBS_FULL MDB_DUPFIXED MDB_FIXEDMAP MDB_GET_BOTH MDB_KEYEXIST MDB_LAST_DUP MDB_MAPASYNC MDB_MAP_FULL MDB_MULTIPLE MDB_NEXT_DUP MDB_NOSUBDIR MDB_NOTFOUND MDB_PREV_DUP MDB_TLS_FULL MDB_TXN_FULL MDB_WRITEMAP */ /* Offset 4 gives the best switch position. */ switch (name[4]) { case 'D': if (memEQ(name, "MDB_DBS_FULL", 12)) { /* ^ */ #ifdef MDB_DBS_FULL *iv_return = MDB_DBS_FULL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "MDB_DUPFIXED", 12)) { /* ^ */ #ifdef MDB_DUPFIXED *iv_return = MDB_DUPFIXED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'F': if (memEQ(name, "MDB_FIXEDMAP", 12)) { /* ^ */ #ifdef MDB_FIXEDMAP *iv_return = MDB_FIXEDMAP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'G': if (memEQ(name, "MDB_GET_BOTH", 12)) { /* ^ */ *iv_return = MDB_GET_BOTH; return PERL_constant_ISIV; } break; case 'K': if (memEQ(name, "MDB_KEYEXIST", 12)) { /* ^ */ #ifdef MDB_KEYEXIST *iv_return = MDB_KEYEXIST; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "MDB_LAST_DUP", 12)) { /* ^ */ *iv_return = MDB_LAST_DUP; return PERL_constant_ISIV; } break; case 'M': if (memEQ(name, "MDB_MAPASYNC", 12)) { /* ^ */ #ifdef MDB_MAPASYNC *iv_return = MDB_MAPASYNC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "MDB_MAP_FULL", 12)) { /* ^ */ #ifdef MDB_MAP_FULL *iv_return = MDB_MAP_FULL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "MDB_MULTIPLE", 12)) { /* ^ */ #ifdef MDB_MULTIPLE *iv_return = MDB_MULTIPLE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "MDB_NEXT_DUP", 12)) { /* ^ */ *iv_return = MDB_NEXT_DUP; return PERL_constant_ISIV; } if (memEQ(name, "MDB_NOSUBDIR", 12)) { /* ^ */ #ifdef MDB_NOSUBDIR *iv_return = MDB_NOSUBDIR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "MDB_NOTFOUND", 12)) { /* ^ */ #ifdef MDB_NOTFOUND *iv_return = MDB_NOTFOUND; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'P': if (memEQ(name, "MDB_PREV_DUP", 12)) { /* ^ */ *iv_return = MDB_PREV_DUP; return PERL_constant_ISIV; } break; case 'T': if (memEQ(name, "MDB_TLS_FULL", 12)) { /* ^ */ #ifdef MDB_TLS_FULL *iv_return = MDB_TLS_FULL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "MDB_TXN_FULL", 12)) { /* ^ */ #ifdef MDB_TXN_FULL *iv_return = MDB_TXN_FULL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'W': if (memEQ(name, "MDB_WRITEMAP", 12)) { /* ^ */ #ifdef MDB_WRITEMAP *iv_return = MDB_WRITEMAP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_13 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. MDB_APPENDDUP MDB_BAD_RSLOT MDB_CORRUPTED MDB_FIRST_DUP MDB_NODUPDATA MDB_NOMEMINIT MDB_NORDAHEAD MDB_PAGE_FULL MDB_SET_RANGE */ /* Offset 11 gives the best switch position. */ switch (name[11]) { case 'A': if (memEQ(name, "MDB_NORDAHEAD", 13)) { /* ^ */ #ifdef MDB_NORDAHEAD *iv_return = MDB_NORDAHEAD; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'E': if (memEQ(name, "MDB_CORRUPTED", 13)) { /* ^ */ #ifdef MDB_CORRUPTED *iv_return = MDB_CORRUPTED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'G': if (memEQ(name, "MDB_SET_RANGE", 13)) { /* ^ */ *iv_return = MDB_SET_RANGE; return PERL_constant_ISIV; } break; case 'I': if (memEQ(name, "MDB_NOMEMINIT", 13)) { /* ^ */ #ifdef MDB_NOMEMINIT *iv_return = MDB_NOMEMINIT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "MDB_PAGE_FULL", 13)) { /* ^ */ #ifdef MDB_PAGE_FULL *iv_return = MDB_PAGE_FULL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "MDB_BAD_RSLOT", 13)) { /* ^ */ #ifdef MDB_BAD_RSLOT *iv_return = MDB_BAD_RSLOT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "MDB_NODUPDATA", 13)) { /* ^ */ #ifdef MDB_NODUPDATA *iv_return = MDB_NODUPDATA; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'U': if (memEQ(name, "MDB_APPENDDUP", 13)) { /* ^ */ #ifdef MDB_APPENDDUP *iv_return = MDB_APPENDDUP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "MDB_FIRST_DUP", 13)) { /* ^ */ *iv_return = MDB_FIRST_DUP; return PERL_constant_ISIV; } break; } return PERL_constant_NOTFOUND; } static int constant_14 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. MDB_CP_COMPACT MDB_INTEGERDUP MDB_INTEGERKEY MDB_NEXT_NODUP MDB_NOMETASYNC MDB_PREV_NODUP MDB_REVERSEDUP MDB_REVERSEKEY */ /* Offset 6 gives the best switch position. */ switch (name[6]) { case 'E': if (memEQ(name, "MDB_PREV_NODUP", 14)) { /* ^ */ *iv_return = MDB_PREV_NODUP; return PERL_constant_ISIV; } break; case 'M': if (memEQ(name, "MDB_NOMETASYNC", 14)) { /* ^ */ #ifdef MDB_NOMETASYNC *iv_return = MDB_NOMETASYNC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "MDB_INTEGERDUP", 14)) { /* ^ */ #ifdef MDB_INTEGERDUP *iv_return = MDB_INTEGERDUP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "MDB_INTEGERKEY", 14)) { /* ^ */ #ifdef MDB_INTEGERKEY *iv_return = MDB_INTEGERKEY; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'V': if (memEQ(name, "MDB_REVERSEDUP", 14)) { /* ^ */ #ifdef MDB_REVERSEDUP *iv_return = MDB_REVERSEDUP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "MDB_REVERSEKEY", 14)) { /* ^ */ #ifdef MDB_REVERSEKEY *iv_return = MDB_REVERSEKEY; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'X': if (memEQ(name, "MDB_NEXT_NODUP", 14)) { /* ^ */ *iv_return = MDB_NEXT_NODUP; return PERL_constant_ISIV; } break; case '_': if (memEQ(name, "MDB_CP_COMPACT", 14)) { /* ^ */ #ifdef MDB_CP_COMPACT *iv_return = MDB_CP_COMPACT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_15 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. MDB_BAD_VALSIZE MDB_CURSOR_FULL MDB_GET_CURRENT MDB_MAP_RESIZED MDB_NOOVERWRITE */ /* Offset 4 gives the best switch position. */ switch (name[4]) { case 'B': if (memEQ(name, "MDB_BAD_VALSIZE", 15)) { /* ^ */ #ifdef MDB_BAD_VALSIZE *iv_return = MDB_BAD_VALSIZE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'C': if (memEQ(name, "MDB_CURSOR_FULL", 15)) { /* ^ */ #ifdef MDB_CURSOR_FULL *iv_return = MDB_CURSOR_FULL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'G': if (memEQ(name, "MDB_GET_CURRENT", 15)) { /* ^ */ *iv_return = MDB_GET_CURRENT; return PERL_constant_ISIV; } break; case 'M': if (memEQ(name, "MDB_MAP_RESIZED", 15)) { /* ^ */ #ifdef MDB_MAP_RESIZED *iv_return = MDB_MAP_RESIZED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "MDB_NOOVERWRITE", 15)) { /* ^ */ #ifdef MDB_NOOVERWRITE *iv_return = MDB_NOOVERWRITE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_16 (pTHX_ const char *name, IV *iv_return, const char **pv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. MDB_GET_MULTIPLE MDB_INCOMPATIBLE MDB_LAST_ERRCODE MDB_READERS_FULL MDB_VERSION_DATE MDB_VERSION_FULL */ /* Offset 4 gives the best switch position. */ switch (name[4]) { case 'G': if (memEQ(name, "MDB_GET_MULTIPLE", 16)) { /* ^ */ *iv_return = MDB_GET_MULTIPLE; return PERL_constant_ISIV; } break; case 'I': if (memEQ(name, "MDB_INCOMPATIBLE", 16)) { /* ^ */ #ifdef MDB_INCOMPATIBLE *iv_return = MDB_INCOMPATIBLE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "MDB_LAST_ERRCODE", 16)) { /* ^ */ #ifdef MDB_LAST_ERRCODE *iv_return = MDB_LAST_ERRCODE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "MDB_READERS_FULL", 16)) { /* ^ */ #ifdef MDB_READERS_FULL *iv_return = MDB_READERS_FULL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'V': if (memEQ(name, "MDB_VERSION_DATE", 16)) { /* ^ */ *pv_return = MDB_VERSION_DATE; return PERL_constant_ISPV; } if (memEQ(name, "MDB_VERSION_FULL", 16)) { /* ^ */ #ifdef MDB_VERSION_FULL *iv_return = MDB_VERSION_FULL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_17 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. MDB_NEXT_MULTIPLE MDB_PAGE_NOTFOUND MDB_VERSION_MAJOR MDB_VERSION_MINOR MDB_VERSION_PATCH */ /* Offset 14 gives the best switch position. */ switch (name[14]) { case 'J': if (memEQ(name, "MDB_VERSION_MAJOR", 17)) { /* ^ */ #ifdef MDB_VERSION_MAJOR *iv_return = MDB_VERSION_MAJOR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "MDB_VERSION_MINOR", 17)) { /* ^ */ #ifdef MDB_VERSION_MINOR *iv_return = MDB_VERSION_MINOR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'P': if (memEQ(name, "MDB_NEXT_MULTIPLE", 17)) { /* ^ */ *iv_return = MDB_NEXT_MULTIPLE; return PERL_constant_ISIV; } break; case 'T': if (memEQ(name, "MDB_VERSION_PATCH", 17)) { /* ^ */ #ifdef MDB_VERSION_PATCH *iv_return = MDB_VERSION_PATCH; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'U': if (memEQ(name, "MDB_PAGE_NOTFOUND", 17)) { /* ^ */ #ifdef MDB_PAGE_NOTFOUND *iv_return = MDB_PAGE_NOTFOUND; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant (pTHX_ const char *name, STRLEN len, IV *iv_return, const char **pv_return) { /* Initially switch on the length of the name. */ /* When generated this function returned values for the list of names given in this section of perl code. Rather than manually editing these functions to add or remove constants, which would result in this comment and section of code becoming inaccurate, we recommend that you edit this section of code, and use it to regenerate a new set of constant functions which you then use to replace the originals. Regenerate these constant functions by feeding this entire source file to perl -x #!/usr/bin/perl -w use ExtUtils::Constant qw (constant_types C_constant XS_constant); my $types = {map {($_, 1)} qw(IV PV)}; my @names = (qw(LMDB_OFLAGN MDB_APPEND MDB_APPENDDUP MDB_BAD_DBI MDB_BAD_RSLOT MDB_BAD_TXN MDB_BAD_VALSIZE MDB_CORRUPTED MDB_CP_COMPACT MDB_CREATE MDB_CURRENT MDB_CURSOR_FULL MDB_DBS_FULL MDB_DUPFIXED MDB_DUPSORT MDB_FIXEDMAP MDB_INCOMPATIBLE MDB_INTEGERDUP MDB_INTEGERKEY MDB_INVALID MDB_KEYEXIST MDB_LAST_ERRCODE MDB_MAPASYNC MDB_MAP_FULL MDB_MAP_RESIZED MDB_MULTIPLE MDB_NODUPDATA MDB_NOLOCK MDB_NOMEMINIT MDB_NOMETASYNC MDB_NOOVERWRITE MDB_NORDAHEAD MDB_NOSUBDIR MDB_NOSYNC MDB_NOTFOUND MDB_NOTLS MDB_PAGE_FULL MDB_PAGE_NOTFOUND MDB_PANIC MDB_RDONLY MDB_READERS_FULL MDB_RESERVE MDB_REVERSEDUP MDB_REVERSEKEY MDB_SUCCESS MDB_TLS_FULL MDB_TXN_FULL MDB_VERSION_FULL MDB_VERSION_MAJOR MDB_VERSION_MINOR MDB_VERSION_MISMATCH MDB_VERSION_PATCH MDB_WRITEMAP), {name=>"MDB_FIRST", type=>"IV", macro=>"1"}, {name=>"MDB_FIRST_DUP", type=>"IV", macro=>"1"}, {name=>"MDB_GET_BOTH", type=>"IV", macro=>"1"}, {name=>"MDB_GET_BOTH_RANGE", type=>"IV", macro=>"1"}, {name=>"MDB_GET_CURRENT", type=>"IV", macro=>"1"}, {name=>"MDB_GET_MULTIPLE", type=>"IV", macro=>"1"}, {name=>"MDB_LAST", type=>"IV", macro=>"1"}, {name=>"MDB_LAST_DUP", type=>"IV", macro=>"1"}, {name=>"MDB_NEXT", type=>"IV", macro=>"1"}, {name=>"MDB_NEXT_DUP", type=>"IV", macro=>"1"}, {name=>"MDB_NEXT_MULTIPLE", type=>"IV", macro=>"1"}, {name=>"MDB_NEXT_NODUP", type=>"IV", macro=>"1"}, {name=>"MDB_PREV", type=>"IV", macro=>"1"}, {name=>"MDB_PREV_DUP", type=>"IV", macro=>"1"}, {name=>"MDB_PREV_NODUP", type=>"IV", macro=>"1"}, {name=>"MDB_SET", type=>"IV", macro=>"1"}, {name=>"MDB_SET_KEY", type=>"IV", macro=>"1"}, {name=>"MDB_SET_RANGE", type=>"IV", macro=>"1"}, {name=>"MDB_VERSION_DATE", type=>"PV", macro=>"1"}, {name=>"MDB_VERSION_STRING", type=>"PV", macro=>"1"}); print constant_types(), "\n"; # macro defs foreach (C_constant ("LMDB_File", 'constant', 'IV', $types, undef, 3, @names) ) { print $_, "\n"; # C constant subs } print "\n#### XS Section:\n"; print XS_constant ("LMDB_File", $types); __END__ */ switch (len) { case 7: if (memEQ(name, "MDB_SET", 7)) { *iv_return = MDB_SET; return PERL_constant_ISIV; } break; case 8: return constant_8 (aTHX_ name, iv_return); break; case 9: return constant_9 (aTHX_ name, iv_return); break; case 10: return constant_10 (aTHX_ name, iv_return); break; case 11: return constant_11 (aTHX_ name, iv_return); break; case 12: return constant_12 (aTHX_ name, iv_return); break; case 13: return constant_13 (aTHX_ name, iv_return); break; case 14: return constant_14 (aTHX_ name, iv_return); break; case 15: return constant_15 (aTHX_ name, iv_return); break; case 16: return constant_16 (aTHX_ name, iv_return, pv_return); break; case 17: return constant_17 (aTHX_ name, iv_return); break; case 18: /* Names all of length 18. */ /* MDB_GET_BOTH_RANGE MDB_VERSION_STRING */ /* Offset 17 gives the best switch position. */ switch (name[17]) { case 'E': if (memEQ(name, "MDB_GET_BOTH_RANG", 17)) { /* E */ *iv_return = MDB_GET_BOTH_RANGE; return PERL_constant_ISIV; } break; case 'G': if (memEQ(name, "MDB_VERSION_STRIN", 17)) { /* G */ *pv_return = MDB_VERSION_STRING; return PERL_constant_ISPV; } break; } break; case 20: if (memEQ(name, "MDB_VERSION_MISMATCH", 20)) { #ifdef MDB_VERSION_MISMATCH *iv_return = MDB_VERSION_MISMATCH; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } LMDB_File-0.13/META.yml0000644000175600003110000000127114552575256012727 0ustar sogsoft--- abstract: "Tie to LMDB (OpenLDAP's Lightning Memory-Mapped Database)" author: - 'Salvador Ortiz ' build_requires: ExtUtils::MakeMaker: '0' Test::Exception: '0' Test::More: '0' configure_requires: ExtUtils::MakeMaker: '6.64' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010' license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: LMDB_File no_index: directory: - t - inc requires: perl: '5.010000' resources: repository: git://github.com/salortiz/LMDB_File.git version: '0.13' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' LMDB_File-0.13/LICENSE0000644000175600003110000002153013042163164012443 0ustar sogsoftThis software is Copyright (c) 2013-2017 by Salvador Ortiz. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) The Artistic License 2.0 Copyright (c) 2000-2006, The Perl Foundation. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. Definitions "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. "You" and "your" means any person who would like to copy, distribute, or modify the Package. "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. "Source" form means the source code, documentation source, and configuration files for the Package. "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. Permission for Use and Modification Without Distribution (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. Permissions for Redistribution of the Standard Version (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. Distribution of Modified Versions of the Package as Source (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. Aggregating or Linking the Package (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. Items That are Not Considered Part of a Modified Version (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. General Provisions (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. LMDB_File-0.13/README0000644000175600003110000000412514474732617012336 0ustar sogsoftLMDB_File version 0.13 ====================== LMDB_File is a Perl wrapper around the OpenLDAP's LMDB (Lightning Memory-Mapped Database) C library. LMDB is an ultra-fast, ultra-compact key-value data store developed by Symas for the OpenLDAP Project. See http://symas.com/mdb/ for details. LMDB_File provides full access to the complete C API, a thin Perl wrapper with an Object-Oriented interface and a simple Perl's tie interface compatible with others DBMs. PREREQUISITES Right now LMDB needs a 64bits platform. Before you can build LMDB_File you need to have the following installed on your system: * Perl 5.10.0 up to 5.38 linked with pthreads. See https://rt.perl.org/Public/Bug/Display.html?id=122906 * A working C compiler. * LMDB Version 0.9.17 or greater (previous versions may work but will miss some features) Some Linux distributions are now including it: * Fedora 20+ `yum install lmdb-devel` * Ubuntu `apt-get install liblmdb-dev` If the library and its header file isn't found installed in your system, Makefile.PL will try to use Doug Hoyte's Alien::LMDB module if available. Otherwise, if you getting this from GitHub, a submodule is included in 'liblmdb' that you can use, please check git documentation to populate the directory. * To run the test harness for this module: - You must make sure that the directory where you have untarred this module is NOT a network drive, e.g. NFS or AFS. - You need the Test::Exception module installed. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install *** WARNING *** This is an early release to allow the interested people the testing and discussion of the module: there is some missing features and you should be aware that the API isn't in stone yet. See TODO COPYRIGHT AND LICENCE Copyright (C) 2013-2023 by Salvador Ortiz Garcia This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License version 2.0. LMDB_File-0.13/t/0000755000175600003110000000000014552575256011720 5ustar sogsoftLMDB_File-0.13/t/02-named.t0000644000175600003110000000617512423636166013412 0ustar sogsoft#!perl use Test::More tests => 50; use Test::Exception; use strict; use warnings; use utf8; use File::Temp; use LMDB_File qw(:flags :cursor_op); my $dir = File::Temp->newdir('mdbtXXXX', TMPDIR => 1, EXLOCK => 0); ok(-d $dir, "Created test dir $dir"); my $env = LMDB::Env->new($dir, { maxdbs => 5 }); { is($env->BeginTxn->OpenDB->stat->{entries}, 0, 'Empty'); } { my $txn = $env->BeginTxn; my $mdb = $txn->OpenDB; ok($mdb, "Main DB Opened"); is($mdb->stat->{entries}, 0, 'Empty'); throws_ok { $txn->OpenDB('SOME'); } qr/NOTFOUND/, 'No created yet'; my $DB = $txn->OpenDB('SOME', MDB_CREATE); ok($DB, "SOME DB Opened"); is($mdb->stat->{entries}, 1, 'Created'); } { my $txn = $env->BeginTxn; is($txn->OpenDB->stat->{entries}, 0, 'Empty'); throws_ok { $txn->OpenDB('SOME'); } qr/NOTFOUND/, 'No preserved'; } { my $txn = $env->BeginTxn; $txn->AutoCommit(1); ok(my $odb = $txn->OpenDB({dbname => 'ONE', flags => MDB_CREATE}), 'ONE Created'); is($odb->[1], 2, 'First One'); $odb->put(Test => 'Hello World'); $odb->put(Test2 => 'A simple string'); is($odb->stat->{entries}, 2, 'In there'); } { my $txn = $env->BeginTxn; ok(my $db = $txn->OpenDB({dbname => 'TWO', flags => MDB_CREATE}), 'TWO Created'); is($db->[1], 3, 'Second One'); is($db->stat->{entries}, 0, 'Empty'); ok(!$db->get('Test'), "No in this"); } { my $txn = $env->BeginTxn; ok(my $odb = $txn->OpenDB('ONE'), 'Preserved'); is($odb->stat->{entries}, 2, "With 2 keys"); is($odb->get('Test'), 'Hello World', 'In there'); is(LMDB_File->open($txn)->stat->{entries}, 1, 'ONE DB'); throws_ok { $odb->open('TWO'); } qr/NOTFOUND/, 'NO TWO DB'; lives_ok { $odb->drop; } 'ONE emptied'; is($odb->stat->{entries}, 0, 'Removed'); } { my $txn = $env->BeginTxn; # A case insensitive DB ok(my $DBN = $txn->OpenDB('CI', MDB_CREATE), 'CI Created'); $DBN->set_compare(sub { lc($a) cmp lc($b) }); # A Reversed key order DB ok(my $DBR = $DBN->open('RK', MDB_CREATE|MDB_REVERSEKEY), 'RK Created'); my %data; my $c; foreach('A' .. 'Z') { $c = ord($_) - ord('A') + 1; my $k = $_ . chr(ord('Z')+1-$c); my $v = sprintf('Datum #%d', $c); $data{$k} = $v; if($c < 4) { is($DBN->put($k, $v), $v, "Put in CI $k"); is($DBN->stat->{entries}, $c, "Entry CI $c"); is($DBR->put($k, $v), $v, "Put in RK $k"); is($DBR->stat->{entries}, $c, "Entry RK $c"); } else { # Don't be verbose $DBN->put($k, $v); $DBR->put($k, $v); } } is($c, 26, 'All in'); # Check data in random HASH order $c = 5; # Don't be verbose while(my($k, $v) = each %data) { is($DBN->get(lc $k), $v, "Get CI \L$k"); is($DBR->get($k), $v, "Get RK $k"); --$c or last; } my $ordkey = [ sort keys %data ]; tie %data, $DBN; is_deeply( $ordkey, [ keys %data ], 'Ordered'); untie %data; tie %data, $DBR; is_deeply( $ordkey, [ reverse keys %data ], 'Reversed' ); untie %data; } END { unless($ENV{KEEP_TMPS}) { for($dir) { unlink glob("$_/*"); rmdir $_; #warn "Removed $_\n"; } } } LMDB_File-0.13/t/00-basic.t0000644000175600003110000000306212422257127013370 0ustar sogsoft#!perl use strict; use warnings; use Test::More tests => 3; BEGIN { use_ok('LMDB_File') }; LMDB_File->import(':all'); my $fail = 0; foreach my $constname (qw( MDB_APPEND MDB_APPENDDUP MDB_BAD_RSLOT MDB_CORRUPTED MDB_CREATE MDB_CURRENT MDB_CURSOR_FULL MDB_DBS_FULL MDB_DUPFIXED MDB_DUPSORT MDB_FIRST MDB_FIRST_DUP MDB_FIXEDMAP MDB_GET_BOTH MDB_GET_BOTH_RANGE MDB_GET_CURRENT MDB_GET_MULTIPLE MDB_INCOMPATIBLE MDB_INTEGERDUP MDB_INTEGERKEY MDB_INVALID MDB_KEYEXIST MDB_LAST MDB_LAST_DUP MDB_LAST_ERRCODE MDB_MAPASYNC MDB_MAP_FULL MDB_MAP_RESIZED MDB_MULTIPLE MDB_NEXT MDB_NEXT_DUP MDB_NEXT_MULTIPLE MDB_NEXT_NODUP MDB_NODUPDATA MDB_NOMETASYNC MDB_NOOVERWRITE MDB_NOSUBDIR MDB_NOSYNC MDB_NOTFOUND MDB_NOTLS MDB_PAGE_FULL MDB_PAGE_NOTFOUND MDB_PANIC MDB_PREV MDB_PREV_DUP MDB_PREV_NODUP MDB_RDONLY MDB_READERS_FULL MDB_RESERVE MDB_REVERSEDUP MDB_REVERSEKEY MDB_SET MDB_SET_KEY MDB_SET_RANGE MDB_SUCCESS MDB_TLS_FULL MDB_TXN_FULL MDB_VERSION_FULL MDB_VERSION_MAJOR MDB_VERSION_MINOR MDB_VERSION_MISMATCH MDB_VERSION_PATCH MDB_VERSION_STRING MDB_VERSION_DATE MDB_WRITEMAP)) { next if (eval "my \$a = $constname; 1"); if ($@ =~ /^Your vendor has not defined LMDB macro $constname/) { print "# pass: $@"; } else { print "# fail: $@"; $fail = 1; } } ok( $fail == 0 , 'Constants' ); ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. my $version = LMDB_File::version(my($major, $minor, $path)); ok($version, "Version $version"); LMDB_File-0.13/t/04-bigone.t0000644000175600003110000000356312423637004013561 0ustar sogsoft#!perl use Test::More tests => 14; use Test::Exception; use strict; use warnings; use File::Temp; use LMDB_File qw(:flags :cursor_op); my $hastr = eval { require Time::HiRes; \&Time::HiRes::gettimeofday }; my $dir = File::Temp->newdir('mdbtXXXX', TMPDIR => 1, EXLOCK => 0); my $mode = MDB_INTEGERKEY; my $packer = 'I'; my $howmany = 2_000_000; ok(my $env = LMDB::Env->new($dir, { mapsize => 50*1024*1024, maxdbs => 2 } ), 'Env created' ); { ok(my $txn = $env->BeginTxn, 'Txn created'); ok(my $dbi = $txn->open('id1', $mode|MDB_CREATE), 'DB opened'); isa_ok(my $db = LMDB_File->new($txn, $dbi), 'LMDB_File'); is($db->flags & $mode, $mode, 'Flag setted'); my $t0 = [ $hastr->() ] if $hastr; for( my $i = 0; $i < $howmany; $i++ ) { $txn->put($dbi, $i, pack($packer, $i) ); } is($db->stat->{entries}, $howmany, '2M entries writen'); diag(sprintf "Writen %d in %g seconds", $howmany, Time::HiRes::tv_interval($t0)) if $hastr; $txn->commit; $db = $env->BeginTxn->OpenDB('id1'); my $cur = $db->Cursor; my ($k, $d, $c); $t0 = [ $hastr->() ] if $hastr; for( my $i = 0; $i < $howmany; $i++ ) { $cur->_get($k, $d, $i ? MDB_PREV : MDB_LAST ); # Uses fast version unless($i) { is($k, $howmany - 1, 'Last'); is(length($d), length(pack('L', 0)), 'Packed'); is(unpack($packer, $d), $k, 'Match'); } $c+=$k; } diag(sprintf "Readed %d in %g seconds", $howmany, Time::HiRes::tv_interval($t0)) if $hastr; is($c, ($howmany-1) * $howmany / 2, 'Sum OK'); is($k, 0, 'First'); ok($d, 'Has value'); is(length($d), length(pack($packer, 1)), 'Packed'); is(unpack('L', $d), 0, 'Match'); my $stat = $db->stat; note "$_: $stat->{$_}" for(keys %{ $stat }); } END { unless($ENV{KEEP_TMPS}) { for($dir) { unlink glob("$_/*"); rmdir $_; #warn "Removed $_\n"; } } } LMDB_File-0.13/t/01-environment.t0000644000175600003110000002617113441552402014656 0ustar sogsoft#!perl use strict; use warnings; use Test::More tests => 174; use Test::Exception; use Encode; use File::Temp; use LMDB_File qw(:envflags :cursor_op); # The tests needs 'C' LC_MESSAGES eval { require POSIX; POSIX::setlocale(POSIX::LC_ALL(), 'C'); }; throws_ok { LMDB::Env->new("NoSuChDiR"); } qr/No such|cannot find/, 'Directory must exists'; my $dir = File::Temp->newdir('mdbtXXXX', TMPDIR => 1, EXLOCK => 0); ok(-d $dir, "Created $dir"); my $testdir = "TestDir"; throws_ok { LMDB::Env->new($dir, { flags => MDB_RDONLY }); } qr/No such|cannot find/, 'RO must exists'; { my $env = new_ok('LMDB::Env' => [ $dir ], "Create Environment") or BAIL_OUT("Can't create environment, test the LMDB library first!"); ok(-e "$dir/data.mdb", 'Data file created exists'); ok(-e "$dir/lock.mdb", 'Lock file created exists'); $env->get_path(my $dummy); is($dir, $dummy, 'get_path'); # Environment flags { $env->get_flags($dummy); my $expflags = $^O =~ /openbsd/ ? MDB_WRITEMAP : # Forced, sorry 0x0; # None set is($dummy, $expflags, 'Flags setted'); # Using private } ok($env->id, 'Env ID: ' . $env->id); # Basic Environment info isa_ok(my $envinfo = $env->info, 'HASH', 'Get Info'); ok(exists $envinfo->{$_}, "Info has $_") for qw(mapaddr mapsize last_pgno last_txnid maxreaders numreaders); ok(!exists $envinfo->{SomeOther}, 'Not in info'); is($envinfo->{mapaddr}, 0, 'Not mapfixed'); is($envinfo->{mapsize}, 1024 * 1024, 'Stock mapsize'); is($envinfo->{maxreaders}, 126, 'Default maxreders'); is($envinfo->{numreaders}, 0, 'No readers'); isa_ok(my $stat = $env->stat, 'HASH', 'Get Stat'); ok(exists $stat->{$_}, "Stat has $_") for qw(psize depth branch_pages leaf_pages overflow_pages entries); # psize differs on various platforms #is($stat->{psize}, 4096, 'Default psize'); is($stat->{$_}, 0, "$_ = 0, empty") for qw(depth branch_pages leaf_pages overflow_pages entries); # Check Internals { my @envid = keys %LMDB::Env::Envs; is(scalar(@envid), 1, 'One Environment'); is($envid[0], $$env, 'The active one'); my $ed = $LMDB::Env::Envs{$$env}; isa_ok($ed, 'ARRAY'); is(scalar @{ $ed }, 4, 'Size'); isa_ok($ed->[0], 'ARRAY', 'Txns'); isa_ok($ed->[1], 'ARRAY', 'DCmps'); isa_ok($ed->[2], 'ARRAY', 'Cmps'); isa_ok(\$ed->[3], 'SCALAR', 'OFlags'); } # Check Env refcounts is(Internals::SvREFCNT($$env), 1, 'Env Inactive'); isa_ok(my $txn = $env->BeginTxn, 'LMDB::Txn', 'Transaction'); ok($txn->_id > 0, 'Expected'); is($txn->_id, $$txn, "Txn Id ($$txn)"); is(Internals::SvREFCNT($$txn), 1, 'Txn active'); is(Internals::SvREFCNT($$env), 2, 'Env Active'); throws_ok { $txn->OpenDB('NAMED'); } qr/limit reached/, 'No named allowed'; SKIP: { skip "Unsuported with MDB_WRITEMAP", 2 if $dummy & MDB_WRITEMAP; isa_ok(my $sub = $env->BeginTxn, 'LMDB::Txn', 'Subtransaction'); is(Internals::SvREFCNT($$env), 3, 'Env Active'); } is(Internals::SvREFCNT($$env), 2, 'Back normal'); { isa_ok(my $eclone = $txn->env, 'LMDB::Env', 'Got Env'); is($env->id, $eclone->id, "The same env ID ($$env)"); is(Scalar::Util::refaddr($env), Scalar::Util::refaddr($eclone), 'Same refaddr'); is(Internals::SvREFCNT($$env), 3, 'Refcounted'); } is(Internals::SvREFCNT($$env), 2, 'Back normal'); lives_ok { $txn->commit; is(Internals::SvREFCNT($$env), 1, 'Env free'); } 'Null Commit'; throws_ok { $txn->commit; } qr/Terminated/, 'Terminated'; is($$txn, 0, 'Nullified'); is($txn->_id, 0, 'The same'); ok($txn = $env->BeginTxn, 'Recreated'); # Open main DB isa_ok(my $DB = $txn->OpenDB, 'LMDB_File', 'DBI created'); is($DB->Alive, 1, 'The first'); is($DB->flags, 0, 'Main DBI Flags'); is($env->info->{numreaders}, 0, "I'm not a reader"); is(Internals::SvREFCNT($$txn), 2, 'DB Keeps Txn'); is($txn->OpenDB->Alive, $DB->Alive, 'Just a clone'); # Put some data my %data; my $c; foreach('A' .. 'Z') { $c = ord($_) - ord('A') + 1; my $k = $_ x 4; my $v = sprintf('Datum #%d', $c); $data{$k} = $v; # Keep a copy, for testing if($c < 4) { is($DB->put($k, $v), $v, "Put $k"); is($DB->stat->{entries}, $c, "Entry $c"); } else { # Don't be verbose $DB->put($k, $v); } } is($c, 26, 'All in'); # Check data in random HASH order $c = 5; # Don't be verbose while(my($k, $v) = each %data) { is($DB->get($k), $v, "Get $k") if(--$c >= 0); } { # Check UTF8 Handling use utf8; use Devel::Peek; my $unicode = "♠♡♢♣"; # U+2660 .. U+2663 is(length $unicode, 4, 'Four unicode characters'); my $invariant = "áéíóú"; my $latin1 = Encode::encode('Latin1', $invariant); # Without explicit help of LMDB_File we need extra care is($DB->put('UNIC', $unicode), $unicode, 'Put unicode'); my $data = $DB->get('UNIC'); isnt($data, $unicode, 'Not the same!'); { use bytes; ok($data eq $unicode, 'Ugly!'); } # Use Latin1 is($DB->put('UNIC2', $latin1), $latin1, 'Put latin1'); $data = $DB->get('UNIC2'); is($data, $latin1, 'By chance'); # But beware is($data, $invariant, 'By perl magic'); { use bytes; ok($data ne $invariant, 'ne OK!?'); } # Safe only if use explicit encode/decode my $encoded = Encode::encode_utf8($unicode); is($DB->put('ENC1', $encoded), $encoded, 'Put encoded'); $data = $DB->get('ENC1'); isnt($data, $unicode, 'Need decode'); is(Encode::decode_utf8($data), $unicode, 'Decode'); is(Encode::decode('Latin1', $DB->get('UNIC2')), $invariant, 'Should'); # Easier with explicit help is($DB->UTF8(1), 0, 'Was off'); is($DB->put('UNIC', $unicode), $unicode, 'Just put in'); is($DB->get('UNIC'), $unicode, 'Just get out'); $data = do { use bytes; $DB->get('UNIC'); }; is($data, $encoded, 'Handy'); { # Be permisive my $warn; local $SIG{__WARN__} = sub { $warn = shift }; $data = $DB->get('UNIC2'); like($warn, qr/Malformed/, 'Warning emited'); ok(!utf8::is_utf8($data), 'No UTF8'); is($data, $latin1, 'But just works'); $warn = ''; # Can correct that. is($DB->put('UNIC2', $latin1), $latin1, 'Just put encoded'); ok(!utf8::is_utf8($latin1), 'Orig not touched'); $data = $DB->get('UNIC2'); is($data, $invariant, 'Must be'); { use bytes; ok($data eq $invariant, 'No suprises'); } is($data, $latin1, 'Just get out encoded'); { use bytes; ok($data ne $latin1, 'Expected'); } ok($warn eq '', 'No more warnings'); } is($DB->get('ENC1'), $unicode, 'Safe played'); is($DB->get('AAAA'), $data{'AAAA'}, 'Unaltered'); $DB->del($_) for qw(UNIC UNIC2 ENC1); } # Commit lives_ok { $txn->commit; } 'Commited'; # Commit terminates transaction and DB ok(!$DB->Alive, "Not Alive"); is($DB->Txn, undef, "No Txn"); is($DB->dbi, 1, "Last memory of dbi"); throws_ok { $DB->get('SOMEKEY'); } qr/Not an active/, 'Commit invalidates DB'; throws_ok { $txn->OpenDB; } qr/Not an alive/, 'Commit finalized txn'; lives_ok { my $warn; local $SIG{__WARN__} = sub { $warn = shift }; $txn->abort; like($warn, qr/Terminated/, 'Warning emited'); is($txn->_id, 0, 'Expected 0'); is($$txn, 0, 'A ghost...'); $warn = ''; # Clean; undef $txn; ok(!$warn, 'No warnings'); } 'but blessed'; is(Internals::SvREFCNT($$env), 1, 'Env Inactive'); is($env->info->{numreaders}, 0, 'No readers yet'); # Test copy method throws_ok { $env->copy($testdir); } qr/No such/, 'Copy needs a directory'; throws_ok { $env->copy($dir); } qr/file exists|error/i, 'An empty one, not myself'; SKIP: { skip "Need a local directory", 2 unless(-d $testdir or mkdir $testdir); is($env->copy($testdir), 0, 'Copied'); my $size = -s "$testdir/data.mdb"; ok($size, "Data file created, $size"); } $testdir = $dir unless -s "$testdir/data.mdb"; { open(my $fd, '>', "$testdir/other.mdb"); is($env->copyfd($fd), 0, 'Copied to HANDLE'); #is($env->info->{numreaders}, 1, 'A reader'); } isa_ok($DB = LMDB_File->new($env->BeginTxn(MDB_RDONLY), 1), 'LMDB_File', 'DBI fast opened RO'); throws_ok { $DB->put('0000', 'Datum #0'); } qr/Permission denied/, 'Read only transaction'; is($env->info->{numreaders}, 1, "I'm a reader"); is($DB->stat->{entries}, 26, 'Has my data'); # Read using cursors isa_ok(my $cursor = $DB->Cursor, 'LMDB::Cursor', 'A cursor'); is($cursor->dbi, $DB->Alive, 'Get DBI'); $cursor->get(my $key, my $datum, MDB_FIRST); is($key, 'AAAA', 'First key'); is($datum, 'Datum #1', 'First datum'); throws_ok { $cursor->get($key, $datum, MDB_PREV); } qr/NOTFOUND/, 'No previous key'; $cursor->get($key, $datum, MDB_NEXT); is($key, 'BBBB', 'Next key'); is($datum, 'Datum #2', 'Next datum'); $cursor->get($key, $datum, MDB_LAST); is($key, 'ZZZZ', 'Last key'); is($datum, 'Datum #26', 'Last datum'); $cursor->get($key, $datum, MDB_PREV); is($key, 'YYYY', 'Previous key'); is($datum, 'Datum #25', 'Previous datum'); $key = $datum = ''; $cursor->get($key, $datum, MDB_GET_CURRENT); is($key, 'YYYY', 'Current key'); is($datum, 'Datum #25', 'Current datum'); throws_ok { # Most cursor_ops need to return the key $cursor->get('CCCC', $datum, MDB_GET_CURRENT); } qr/read-only value/, 'Need lvalue'; lives_ok { # Some accept a constant $cursor->get('CCCC', $datum, MDB_SET); } 'Can be constant'; is($datum, 'Datum #3', 'lookup datum'); throws_ok { $cursor->get($key = 'ZABC', $datum, MDB_SET); } qr/NOTFOUND/, 'Not found'; $cursor->get($key, $datum, MDB_SET_RANGE); is($key, 'ZZZZ', 'Got last key'); is($datum, 'Datum #26', 'Got last datum'); throws_ok { $cursor->get($key, $datum, MDB_NEXT); } qr/NOTFOUND/, 'No next key'; } is(scalar keys %LMDB::Env::Envs, 0, 'No environment open'); { # Using TIE interface my $h; isa_ok( tie(%$h, 'LMDB_File', "$testdir/other.mdb" => { flags => MDB_NOSUBDIR, mapsize => 2 * 1024 * 1024, }), 'LMDB_File', 'Tied' ); { # Consistency checks isa_ok(my $DB = tied %$h, 'LMDB_File', 'The same'); isa_ok(my $txn = $DB->Txn, 'LMDB::Txn', 'Has Txn'); isa_ok(my $env = $txn->env, 'LMDB::Env'); is($env->info->{mapsize}, 2 * 1024 * 1024, 'mapsize increased'); is($DB->dbi, 1, 'The default one'); } # Check optimized scalar ok(scalar %$h, 'Has data'); is($h->{EEEE}, 'Datum #5', 'FETCH'); is($h->{ABCS}, undef, 'No data'); my @keys = keys %{$h}; is(scalar @keys, 26, 'Size'); is_deeply(['A'..'Z'], [ map substr($_, 0, 1), @keys ], 'All in'); ok(exists $h->{ZZZZ}, 'Exists'); is(delete $h->{ZZZZ}, 'Datum #26', 'Deleted #26'); ok(!exists $h->{ZZZZ}, 'Really deleted'); is(scalar %$h, 25, 'Reduced'); is($h->{ZZZZ} = 'New data', 'New data', 'STORE'); is(scalar %$h, 26, 'Stored'); is($h->{ZZZZ}, 'New data', 'Really stored'); %$h = (); ok(!scalar %$h, 'Emptied'); %$h = (a => 1, b => 2, c=>3); is(scalar %$h, 3, 'Loaded'); # Check each while(my($k, $v) = each %$h) { is(ord($k)-96,$v, "Match for $k"); } untie %$h; } END { unless($ENV{KEEP_TMPS}) { for($testdir, $dir) { unlink glob("$_/*"); rmdir or warn "rm $_: $!\n"; #warn "Removed $_\n"; } } } LMDB_File-0.13/t/03-fastmode.t0000644000175600003110000001240213441552402014106 0ustar sogsoft#!perl use strict; use warnings; use utf8; use Test::More tests => 53; use Test::Exception; #use Test::ZeroCopy; use B; use Benchmark qw(:hireswallclock); use Config; #use Devel::Peek; #$Devel::Peek::pv_limit = 20; use File::Temp; use LMDB_File qw(:flags :cursor_op); my $dir = File::Temp->newdir('mdbtXXXX', TMPDIR => 1, EXLOCK => 0); ok(-d $dir, "Created test dir $dir"); my $large1 = '0123456789' x 100_000; my $val; { my $env = LMDB::Env->new($dir, { mapsize => 100 * 1024 * 1024 }); ok(my $DB = $env->BeginTxn->OpenDB, 'Open unamed'); is($DB->dbi, 1, 'Opened'); is($DB->put('A' => $large1), $large1, 'Put large value'); $DB->Txn->commit; $DB = LMDB_File->new($env->BeginTxn(MDB_RDONLY), 1); is($DB->ReadMode, 0, 'In normal read mode'); $DB->get('A', $val); is(length($val), 1_000_000, '1MB'); is($val, $large1, 'The value is there'); ok(my $inspec = B::svref_2object(\$val), 'Inspected'); ok($inspec->isa('B::PV'), 'Is a PV'); ok($inspec->LEN > 0, 'Perl owned'); #Dump($val); my $t = timeit(50, sub { $DB->get('A', $val) for (1..1000); }); diag("Normal mode in ", timestr($t)); is($DB->ReadMode(1), 0, 'Previous mode returned'); is($DB->ReadMode, 1, 'In fast read mode'); $DB->get('A', my $fval); #Dump($fval); is(length($fval), 1_000_000, '1MB'); is($fval, $large1, 'The value is there'); ok($inspec = B::svref_2object(\$fval), 'Inspected'); ok($inspec->isa('B::PVMG'), 'Is a PVMG'); is($inspec->LEN, 0, 'Not perl owned'); is($fval, $val, 'Same value'); #isnt_zerocopy($fval, $val, 'Diferent buffer'); throws_ok { $fval = 'Hola'; } qr/read-only/, 'Is ReadOnly'; $t = timeit(50, sub { $DB->get('A', $val) for (1..1000); }); diag("Fast mode in ", timestr($t)); is($fval, $val, 'Same value'); #is_zerocopy($fval, $val, 'Same buffer'); my $oval = $DB->Rget('A'); is($$oval, $val, 'Same value by ref'); #is_zerocopy($$oval, $val, 'Same buffer by ref'); $DB = undef; $DB = LMDB_File->new($env->BeginTxn(MDB_RDONLY), 1); is($DB->ReadMode, 1, 'Preserved fast read mode'); $DB->get('A', $fval); #Dump($fval); TODO: { local $TODO = 'End of Txn should invalidate fastmode magic vars'; ok(!defined($val), 'Was invalidated'); # Commented until fixed ZeroCopy #isnt_zerocopy($fval, $val, 'New Txn, so different buffer'); } my $count = $fval =~ tr/5/5/; is($count, 100_000, 'fives'); throws_ok { $count = $fval =~ tr/5/E/; } qr/read-only/, 'Is RO'; } { # Change environment to MDB_WRITEMAP. my $env = LMDB::Env->new($dir, { flags => MDB_WRITEMAP }); ok(my $DB = $env->BeginTxn->OpenDB, 'Open unamed in WM'); is($DB->ReadMode(1), 0, 'No fast read mode preserved'); $DB->get('A', my $fval); #Dump($fval); # According to cpantesters on Mac OS X and Debian's libc-2.3.6 the # same address for mmap is used!! #isnt_zerocopy($fval, $val, 'New Env, so diferent buffer'); $DB->get('A', $val); for($fval) { # A twist #Dump($_); is($_, $large1, 'The value is there'); my $count; lives_ok { $count = tr/5/E/; } 'Now R/W!'; is($count, 100_000, 'fives replaced'); is(tr/5/5/, 0, 'No more fives'); #is_zerocopy($_, $val, 'Same buffer yet'); isnt($_, $large1, 'The value has changed'); { # Test for warning when indirect writes my $warn; local $SIG{__WARN__} = sub { $warn = shift }; $_ = 'Z' x 9; like($warn, qr/not recommended/, 'Warn emited'); is(length, 1_000_000, 'Length unchanged'); $warn = ''; is(s/123/ABC/g, 99_999, 'Lots changed'); is($warn, '', 'No warn emited'); # Try to extend/grow $_ .= 'hi'; like($warn, qr/Truncating/, 'Truncating warning emited'); is(length, 1_000_000, 'Length unchanged'); is(substr($_, -1, 1), '9', 'Last byte is 9'); } #is_zerocopy($_, $val, 'Same buffer yet'); } SKIP: { skip 'Need ASCII platform', 1 unless 65 == ord 'A'; for(substr($fval, 20, 9)) { $_ |= ('p' x 9); is(uc, 'PQRSTUVWX', 'Bits changed'); } } lives_ok { $DB->Txn->commit(); } 'Changes commited'; isnt($DB->Alive, 'Because Txn terminated'); ($DB->Txn = $env->BeginTxn)->AutoCommit(1); #Nice hack is($DB->Alive, 1, 'Alive again'); is($DB->ReadMode, 1, 'Preserved'); $DB->get('A', $fval); is($fval =~ tr/A/A/, 99_998, 'Changes preserved'); $fval =~ s/9/\n/g; { local $LMDB_File::DEBUG = 1; my $warn; local $SIG{__WARN__} = sub { $warn .= shift }; $DB->Txn = undef; # Commit, another hack like($warn, qr/commiting/, 'In AutoCommit'); like($warn, qr/commited/, 'Commited'); } $DB->Txn = $env->BeginTxn(MDB_RDONLY); SKIP: { skip 'Need perlio and PerlIO::scalar', 6 unless PerlIO::Layer->find('perlio') && $Config{'extensions'} =~ m|PerlIO/scalar|; # Try a nice trick require IO::File; my $io = IO::File->new($DB->Rget('A'), 'r'); isa_ok($io, 'IO::File'); is($io->getline, 'Z' x 9 . "\n"); is($io->getline, "0ABC4E678\n"); is($io->getline, "pqrstuvwx\n"); my($c, $l) = (3, 30); #So far while(<$io>) { $c++; $l += length; } is($c, 100_000, 'All read'); is($l, 1_000_000, 'Complete'); } } END { unless($ENV{KEEP_TMPS}) { for($dir) { unlink glob("$_/*"); rmdir $_; #warn "Removed $_\n"; } } } LMDB_File-0.13/MANIFEST0000644000175600003110000000057114552575256012611 0ustar sogsoftChanges LMDB.xs Makefile.PL MANIFEST ppport.h README TODO LICENSE typemap t/00-basic.t t/01-environment.t t/02-named.t t/03-fastmode.t t/04-bigone.t fallback/const-c.inc fallback/const-xs.inc lib/LMDB_File.pm META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) LMDB_File-0.13/LMDB.xs0000644000175600003110000006500314474670321012543 0ustar sogsoft#define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" /* Perl portability code */ #ifndef cxinc #define cxinc() Perl_cxinc(aTHX) #endif #ifdef SV_UNDEF_RETURNS_NULL #define MySvPV(sv, len) SvPV_flags(sv, len, SV_GMAGIC|SV_UNDEF_RETURNS_NULL) #else #define MySvPV(sv, len) (SvOK(sv)?SvPV_flags(sv, len, SV_GMAGIC):((len=0), NULL)) #endif #ifndef caller_cx /* Copied from pp_ctl.c for pre 5.13.5 */ STATIC I32 S_dopoptosub_at(pTHX_ const PERL_CONTEXT *cxstk, I32 startingblock) { dVAR; I32 i; for (i = startingblock; i >= 0; i--) { register const PERL_CONTEXT * const cx = &cxstk[i]; switch (CxTYPE(cx)) { default: continue; case CXt_EVAL: case CXt_SUB: case CXt_FORMAT: return i; } } return i; } #define dopoptosub_at(c,s) S_dopoptosub_at(aTHX_ c,s) STATIC const PERL_CONTEXT * Perl_caller_cx(pTHX_ I32 count, const PERL_CONTEXT **dbcxp) { I32 cxix = dopoptosub_at(cxstack, cxstack_ix); const PERL_CONTEXT *cx; const PERL_CONTEXT *ccstack = cxstack; const PERL_SI *top_si = PL_curstackinfo; for (;;) { while (cxix < 0 && top_si->si_type != PERLSI_MAIN) { top_si = top_si->si_prev; ccstack = top_si->si_cxstack; cxix = dopoptosub_at(ccstack, top_si->si_cxix); } if (cxix < 0) return NULL; if (PL_DBsub && GvCV(PL_DBsub) && cxix >= 0 && ccstack[cxix].blk_sub.cv == GvCV(PL_DBsub)) count++; if (!count--) break; cxix = dopoptosub_at(ccstack, cxix - 1); } cx = &ccstack[cxix]; if (dbcxp) *dbcxp = cx; if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) { const I32 dbcxix = dopoptosub_at(ccstack, cxix - 1); if (PL_DBsub && GvCV(PL_DBsub) && dbcxix >= 0 && ccstack[dbcxix].blk_sub.cv == GvCV(PL_DBsub)) cx = &ccstack[dbcxix]; } return cx; } #define caller_cx(count, dbcxp) Perl_caller_cx(aTHX_ count, dbcxp); #endif /* * Can't use standard SvPVutf8 because the potential upgrade is in place * and modifying a user scalar in any way is bad practice unless expected. */ STATIC char * S_mySvPVutf8(pTHX_ SV *sv, STRLEN *const len) { if(!SvOK(sv)) { *len = 0; return NULL; } SvGETMAGIC(sv); if(!SvUTF8(sv)) { sv = sv_mortalcopy(sv); sv_utf8_upgrade_nomg(sv); } return SvPV_nomg(sv, *len); } #define MySvPVutf8(sv, len) S_mySvPVutf8(aTHX_ sv, &len) #include /* My own exportable constants */ #define LMDB_OFLAGN 2 #define LMDB_ZEROCOPY 0x0001 #define LMDB_UTF8 0x0002 #include "const-c.inc" #define F_ISSET(w, f) (((w) & (f)) == (f)) #define TOHIWORD(F) ((F) << 16) #define StoreUV(k, v) (void)hv_store(RETVAL, (k), sizeof(k) - 1, newSVuv(v), 0) typedef IV MyInt; /* lifted from Perl core and simplified [rt.cpan.org #148421] */ STATIC UV my_do_vecget(pTHX_ SV *sv, STRLEN offset, int size) { STRLEN srclen; const I32 svpv_flags = ((PL_op->op_flags & OPf_MOD || LVRET) ? SV_UNDEF_RETURNS_NULL : 0); unsigned char *s = (unsigned char *) SvPV_flags(sv, srclen, (svpv_flags|SV_GMAGIC)); UV retnum = 0; if (!s) { s = (unsigned char *)""; } /* aka. PERL_ARGS_ASSERT_DO_VECGET */ assert(sv); /* sanity checks to make sure the premises for our simplifications still hold */ assert(LMDB_OFLAGN <= 8); if (size != LMDB_OFLAGN) Perl_croak(aTHX_ "This is a crippled version of vecget that supports size==%d (LMDB_OFLAGN)", LMDB_OFLAGN); if (SvUTF8(sv)) { if (Perl_sv_utf8_downgrade_flags(aTHX_ sv, TRUE, 0)) { /* PVX may have changed */ s = (unsigned char *) SvPV_flags(sv, srclen, svpv_flags); } else { Perl_croak(aTHX_ "Use of strings with code points over 0xFF" " as arguments to vec is forbidden"); } } STRLEN bitoffs = ((offset % 8) * size) % 8; STRLEN uoffset = offset / (8 / size); if (uoffset >= srclen) return 0; retnum = (s[uoffset] >> bitoffs) & nBIT_MASK(size); return retnum; } static void populateStat(pTHX_ HV** hashptr, int res, MDB_stat *stat) { HV* RETVAL; if(res) croak("%s", mdb_strerror(res)); RETVAL = newHV(); StoreUV("psize", stat->ms_psize); StoreUV("depth", stat->ms_depth); StoreUV("branch_pages", stat->ms_branch_pages); StoreUV("leaf_pages", stat->ms_leaf_pages); StoreUV("overflow_pages", stat->ms_overflow_pages); StoreUV("entries", stat->ms_entries); *hashptr = RETVAL; } typedef MDB_env* LMDB__Env; typedef MDB_txn* LMDB__Txn; typedef MDB_txn* TxnOrNull; typedef MDB_dbi LMDB; typedef MDB_val DBD; typedef MDB_val DBK; typedef MDB_val DBKC; typedef MDB_cursor* LMDB__Cursor; typedef unsigned int flags_t; #define MY_CXT_KEY "LMDB_File::_guts" XS_VERSION typedef struct { LMDB__Env envid; AV *DCmps; AV *Cmps; SV *OFlags; LMDB curdb; unsigned int cflags; SV *my_asv; SV *my_bsv; OP *lmdb_dcmp_cop; } my_cxt_t; START_MY_CXT #define LMDB_OFLAGS TOHIWORD(my_do_vecget(aTHX_ MY_CXT.OFlags, dbi, LMDB_OFLAGN)) #define MY_CMP *av_fetch(MY_CXT.Cmps, MY_CXT.curdb, 1) #define MY_DCMP *av_fetch(MY_CXT.DCmps, MY_CXT.curdb, 1) #define CHECK_ALLCUR \ envid = mdb_txn_env(txn); \ if(envid != MY_CXT.envid) { \ SV* eidx = sv_2mortal(newSVuv(PTR2UV(MY_CXT.envid = envid))); \ HE* enve = hv_fetch_ent(get_hv("LMDB::Env::Envs", 0), eidx, 0, 0); \ AV* hh = (AV*)SvRV(HeVAL(enve)); \ MY_CXT.DCmps = (AV *)SvRV(*av_fetch(hh, 1, 0)); \ MY_CXT.Cmps = (AV *)SvRV(*av_fetch(hh, 2, 0)); \ MY_CXT.OFlags = *av_fetch(hh, 3, 0); \ MY_CXT.curdb = 0; /* Invalidate cached */ \ } \ if(MY_CXT.curdb != dbi) { \ MY_CXT.curdb = dbi; \ mdb_dbi_flags(txn, dbi, &MY_CXT.cflags); \ MY_CXT.cflags |= LMDB_OFLAGS; \ } \ my_cmpsv = MY_CMP; \ my_dcmpsv = MY_DCMP #define ISDBKINT F_ISSET(MY_CXT.cflags, MDB_INTEGERKEY) #define ISDBDINT F_ISSET(MY_CXT.cflags, MDB_DUPSORT|MDB_INTEGERDUP) #define LwZEROCOPY F_ISSET(MY_CXT.cflags, TOHIWORD(LMDB_ZEROCOPY)) #define LwUTF8 F_ISSET(MY_CXT.cflags, TOHIWORD(LMDB_UTF8)) #define dCURSOR MDB_txn* txn; MDB_dbi dbi #define PREC_FLGS(c) txn = mdb_cursor_txn(c); dbi = mdb_cursor_dbi(c); CHECK_ALLCUR #define Sv2DBD(sv, data) \ if(ISDBDINT) { \ SvIV_please(sv); \ data.mv_data = &(((XPVIV*)SvANY(sv))->xiv_iv); \ data.mv_size = sizeof(MyInt); \ } \ else data.mv_data = LwUTF8 ? MySvPVutf8(sv, data.mv_size) \ : MySvPV(sv, data.mv_size) /* ZeroCopy support * * The following code was originally copied from Leon Timmermans's File::Map module * * This software is copyright (c) 2008, 2009 by Leon Timmermans . * This is free software; you can redistribute it and/or modify it under * the same terms as perl itself. */ #define MMAP_MAGIC_NUMBER 0x4c4d struct mmap_info { void* real_address; /* Currently unused */ void* fake_address; size_t real_length; /* Currently unused */ size_t fake_length; int isutf8; #ifdef USE_ITHREADS perl_mutex count_mutex; perl_mutex data_mutex; PerlInterpreter* owner; perl_cond cond; int count; #endif }; static void reset_var(pTHX_ SV* var, struct mmap_info* info) { SvPVX(var) = info->fake_address; SvLEN(var) = 0; SvCUR(var) = info->fake_length; SvPOK_only_UTF8(var); #if DEBUG_AS_DUAL SvUV_set(var, PTR2UV(info->fake_address)); SvIOK_on(var); SvIsUV_on(var); #endif } static void mmap_fixup(pTHX_ SV* var, struct mmap_info* info, const char* string, STRLEN len) { if (ckWARN(WARN_SUBSTR)) { Perl_warn(aTHX_ "Writing directly to a memory mapped var is not recommended"); if (SvCUR(var) > info->fake_length) Perl_warn(aTHX_ "Truncating new value to size of the memory map"); } if (string && len) Copy(string, info->fake_address, MIN(len, info->fake_length), char); SV_CHECK_THINKFIRST_COW_DROP(var); if (SvROK(var)) sv_unref_flags(var, SV_IMMEDIATE_UNREF); if (SvPOK(var)) SvPV_free(var); reset_var(aTHX_ var, info); } static int mmap_write(pTHX_ SV* var, MAGIC* magic) { struct mmap_info* info = (struct mmap_info*) magic->mg_ptr; if (!SvOK(var)) mmap_fixup(aTHX_ var, info, NULL, 0); else if (!SvPOK(var)) { STRLEN len; const char* string = info->isutf8 ? MySvPVutf8(var, len) : SvPV(var, len); mmap_fixup(aTHX_ var, info, string, len); } else if (SvPVX(var) != info->fake_address) mmap_fixup(aTHX_ var, info, SvPVX(var), SvCUR(var)); else SvPOK_only_UTF8(var); return 0; } static int mmap_clear(pTHX_ SV* var, MAGIC* magic) { Perl_die(aTHX_ "Can't clear a mapped variable"); return 0; } static int mmap_free(pTHX_ SV* var, MAGIC* magic) { struct mmap_info* info = (struct mmap_info*) magic->mg_ptr; #ifdef USE_ITHREADS MUTEX_LOCK(&info->count_mutex); if (--info->count == 0) { COND_DESTROY(&info->cond); MUTEX_DESTROY(&info->data_mutex); MUTEX_UNLOCK(&info->count_mutex); MUTEX_DESTROY(&info->count_mutex); PerlMemShared_free(info); } else { MUTEX_UNLOCK(&info->count_mutex); } #else PerlMemShared_free(info); #endif SvREADONLY_off(var); SvPV_free(var); SvPVX(var) = NULL; SvCUR(var) = 0; return 0; } #ifdef USE_ITHREADS static int mmap_dup(pTHX_ MAGIC* magic, CLONE_PARAMS* param) { struct mmap_info* info = (struct mmap_info*) magic->mg_ptr; MUTEX_LOCK(&info->count_mutex); assert(info->count); ++info->count; MUTEX_UNLOCK(&info->count_mutex); return 0; } #else #define mmap_dup 0 #endif #ifdef MGf_LOCAL static int mmap_local(pTHX_ SV* var, MAGIC* magic) { Perl_croak(aTHX_ "Can't localize file map"); } #define mmap_local_tail , mmap_local #else #define mmap_local_tail #endif static MGVTBL mmap_table = { 0, mmap_write, 0, mmap_clear, mmap_free, 0, mmap_dup mmap_local_tail }; static void check_new_variable(pTHX_ SV* var) { if (SvTYPE(var) > SVt_PVMG && SvTYPE(var) != SVt_PVLV) Perl_croak(aTHX_ "Trying to map into a nonscalar!\n"); #ifdef sv_unmagicext sv_unmagicext(var, PERL_MAGIC_uvar, &mmap_table); #else sv_unmagic(var, PERL_MAGIC_uvar); #endif SV_CHECK_THINKFIRST_COW_DROP(var); if (SvREADONLY(var)) Perl_croak(aTHX_ "%s", PL_no_modify); if (SvROK(var)) sv_unref_flags(var, SV_IMMEDIATE_UNREF); if (SvNIOK(var)) SvNIOK_off(var); if (SvPOK(var)) SvPV_free(var); SvUPGRADE(var, SVt_PVMG); } static struct mmap_info* initialize_mmap_info( pTHX_ void* address, size_t len, ptrdiff_t correction, int isutf8 ) { struct mmap_info* info = PerlMemShared_malloc(sizeof *info); info->real_address = address; info->fake_address = (char*)address + correction; info->real_length = len + correction; info->fake_length = len; #ifdef USE_ITHREADS MUTEX_INIT(&info->count_mutex); MUTEX_INIT(&info->data_mutex); COND_INIT(&info->cond); info->count = 1; #endif info->isutf8 = isutf8; return info; } static void add_magic( pTHX_ SV* var, struct mmap_info* info, const MGVTBL* table, int writable ) { MAGIC* magic = sv_magicext(var, NULL, PERL_MAGIC_uvar, table, (const char*) info, 0); magic->mg_private = MMAP_MAGIC_NUMBER; #ifdef MGf_LOCAL magic->mg_flags |= MGf_LOCAL; #endif #ifdef USE_ITHREADS magic->mg_flags |= MGf_DUP; #endif if(info->isutf8) SvUTF8_on(var); else SvUTF8_off(var); SvTAINTED_on(var); if (!writable) SvREADONLY_on(var); } static void sv_setstatic(pTHX_ pMY_CXT_ SV *const sv, MDB_val *data, bool is_res) { if(ISDBDINT && !is_res) sv_setiv_mg(sv, *(MyInt *)data->mv_data); else { const PERL_CONTEXT *cx = caller_cx(0, NULL); int utf8 = LwUTF8 && !(CopHINTS_get(cx ? cx->blk_oldcop : PL_curcop) & HINT_BYTES); if(utf8 && !is_utf8_string(data->mv_data, data->mv_size)) { if(ckWARN(WARN_UTF8)) Perl_warn(aTHX_ "Malformed UTF-8 in get"); utf8 = 0; } if(LwZEROCOPY || is_res) { struct mmap_info* info; unsigned int eflags; int writable; check_new_variable(aTHX_ sv); info = initialize_mmap_info(aTHX_ data->mv_data, data->mv_size, 0, utf8); mdb_env_get_flags(MY_CXT.envid, &eflags); writable = is_res || (F_ISSET(eflags, MDB_WRITEMAP) && !F_ISSET(MY_CXT.cflags, MDB_RDONLY)); add_magic(aTHX_ sv, info, &mmap_table, writable); reset_var(aTHX_ sv, info); } else { sv_setpvn_mg(sv, data->mv_data, data->mv_size); if(utf8) SvUTF8_on(sv); else SvUTF8_off(sv); } } } /* Callback Handling */ static int LMDB_cmp(const MDB_val *a, const MDB_val *b) { dTHX; dMY_CXT; dSP; int ret; ENTER; SAVETMPS; PUSHMARK(SP); sv_setpvn_mg(MY_CXT.my_asv, a->mv_data, a->mv_size); sv_setpvn_mg(MY_CXT.my_bsv, b->mv_data, b->mv_size); call_sv(SvRV(MY_CMP), G_SCALAR|G_NOARGS); SPAGAIN; ret = POPi; PUTBACK; FREETMPS; LEAVE; return ret; } #define CvValid(rcv) (SvROK(rcv) && SvTYPE(SvRV(rcv)) == SVt_PVCV) #define dMCOMMON \ dMY_CXT; \ int needsave = 0; \ SV *my_cmpsv; \ SV *my_dcmpsv; \ LMDB__Env envid #define MY_PUSH_COMMON \ if(CvValid(my_cmpsv)) { \ mdb_set_compare(txn, dbi, LMDB_cmp); \ needsave++; \ } \ if(UNLIKELY(needsave)) { \ SAVESPTR(MY_CXT.my_asv); \ SAVESPTR(MY_CXT.my_bsv); \ } #ifdef dMULTICALL /* If this perl has MULTICALL support, use it for the DATA comparer */ #if PERL_VERSION < 13 || (PERL_VERSION == 13 && PERL_SUBVERSION < 9) #define FIXREFCOUNT if(CvDEPTH(multicall_cv) > 1) \ SvREFCNT_inc_simple_void_NN(multicall_cv) #else #define FIXREFCOUNT #endif #if PERL_VERSION < 23 || (PERL_VERSION == 23 && PERL_SUBVERSION < 8) #define MY_POP_MULTICALL \ if(multicall_cv) { \ FIXREFCOUNT; \ POP_MULTICALL; \ newsp = newsp; \ } #define MYMCINIT multicall_cv = NULL #else #define MY_POP_MULTICALL if(multicall_cop) { POP_MULTICALL; } #if PERL_VERSION == 23 && PERL_SUBVERSION == 8 #define MYMCINIT multicall_oldcatch = 0 #else #define MYMCINIT #endif #endif static int LMDB_dcmp(const MDB_val *a, const MDB_val *b) { dTHX; dMY_CXT; sv_setpvn_mg(MY_CXT.my_asv, a->mv_data, a->mv_size); sv_setpvn_mg(MY_CXT.my_bsv, b->mv_data, b->mv_size); PL_op = MY_CXT.lmdb_dcmp_cop; CALLRUNOPS(aTHX); return SvIV(*PL_stack_sp); } #define dMY_MULTICALL \ dMCOMMON; \ dMULTICALL; \ multicall_cop = NULL; \ I32 gimme = G_SCALAR #define MY_PUSH_MULTICALL \ MYMCINIT; \ if(CvValid(my_dcmpsv)) { \ PUSH_MULTICALL((CV *)SvRV(my_dcmpsv)); \ MY_CXT.lmdb_dcmp_cop = multicall_cop; \ mdb_set_dupsort(txn, dbi, LMDB_dcmp); \ needsave++; \ } \ MY_PUSH_COMMON #else /* NO MULTICALL support, use a slow path */ static int LMDB_dcmp(const MDB_val *a, const MDB_val *b) { dTHX; dMY_CXT; dSP; int ret; ENTER; SAVETMPS; PUSHMARK(SP); sv_setpvn_mg(MY_CXT.my_asv, a->mv_data, a->mv_size); sv_setpvn_mg(MY_CXT.my_bsv, b->mv_data, b->mv_size); call_sv(SvRV(MY_DCMP), G_SCALAR|G_NOARGS); SPAGAIN; ret = POPi; PUTBACK; FREETMPS; LEAVE; return ret; } #define dMY_MULTICALL dMCOMMON #define MY_PUSH_MULTICALL \ if(CvValid(my_dcmpsv)) { \ mdb_set_dupsort(txn, dbi, LMDB_dcmp); \ needsave++; \ } \ MY_PUSH_COMMON #define MY_POP_MULTICALL #endif /* dMULTICALL */ /* Error Handling */ #define DieOnErrSV GvSV(gv_fetchpv("LMDB_File::die_on_err", 0, SVt_IV)) #define DieOnErr SvTRUEx(DieOnErrSV) #define LastErrSV GvSV(gv_fetchpv("LMDB_File::last_err", 0, SVt_IV)) #define ProcError(res) \ if(UNLIKELY(res)) { \ sv_setiv(LastErrSV, res); \ sv_setpv(ERRSV, mdb_strerror(res)); \ if(DieOnErr) croak(NULL); \ XSRETURN_IV(res); \ } MODULE = LMDB_File PACKAGE = LMDB::Env PREFIX = mdb_env_ int mdb_env_create(env) LMDB::Env &env = NO_INIT POSTCALL: ProcError(RETVAL); OUTPUT: env int mdb_env_open(env, path, flags, mode) LMDB::Env env const char * path flags_t flags int mode PREINIT: dMY_CXT; AV* av; SV* eidx; POSTCALL: ProcError(RETVAL); eidx = sv_2mortal(newSVuv(PTR2UV(MY_CXT.envid = env))); av = newAV(); av_store(av, 0, newRV_noinc((SV *)newAV())); /* Txns */ av_store(av, 1, newRV_noinc((SV *)(MY_CXT.DCmps = newAV()))); av_store(av, 2, newRV_noinc((SV *)(MY_CXT.Cmps = newAV()))); av_store(av, 3, (MY_CXT.OFlags = newSVpv("",0))); /* FastMode */ hv_store_ent(get_hv("LMDB::Env::Envs", 0), eidx, newRV_noinc((SV *)av), 0); int mdb_env_copy(env, path, flags = 0) LMDB::Env env const char * path unsigned flags CODE: #if MDB_VERSION_PATCH < 14 if(flags) croak("LMDB_File::copy: This version don't support flags"); RETVAL = mdb_env_copy(env, path); #else RETVAL = mdb_env_copy2(env, path, flags); #endif ProcError(RETVAL); OUTPUT: RETVAL int mdb_env_copyfd(env, fd, flags = 0) LMDB::Env env mdb_filehandle_t fd unsigned flags CODE: #if MDB_VERSION_PATCH < 14 if(flags) croak("LMDB_File::copyfd: This version don't support flags"); RETVAL = mdb_env_copyfd(env, fd); #else RETVAL = mdb_env_copyfd2(env, fd, flags); #endif ProcError(RETVAL); OUTPUT: RETVAL HV* mdb_env_stat(env) LMDB::Env env PREINIT: MDB_stat stat; CODE: populateStat(aTHX_ &RETVAL, mdb_env_stat(env, &stat), &stat); OUTPUT: RETVAL HV* mdb_env_info(env) LMDB::Env env PREINIT: MDB_envinfo stat; int res; CODE: res = mdb_env_info(env, &stat); ProcError(res); RETVAL = newHV(); StoreUV("mapaddr", (uintptr_t)stat.me_mapaddr); StoreUV("mapsize", stat.me_mapsize); StoreUV("last_pgno", stat.me_last_pgno); StoreUV("last_txnid", stat.me_last_txnid); StoreUV("maxreaders", stat.me_maxreaders); StoreUV("numreaders", stat.me_numreaders); OUTPUT: RETVAL int mdb_env_sync(env, force=0) LMDB::Env env int force void mdb_env_close(env) LMDB::Env env PREINIT: dMY_CXT; SV *eidx; POSTCALL: eidx = sv_2mortal(newSVuv(PTR2UV(env))); MY_CXT.envid = (LMDB__Env)hv_delete_ent( get_hv("LMDB::Env::Envs", 0), eidx, G_DISCARD, 0 ); int mdb_env_set_flags(env, flags, onoff) LMDB::Env env unsigned int flags int onoff #define CHANGEABLE (MDB_NOSYNC|MDB_NOMETASYNC|MDB_MAPASYNC|MDB_NOMEMINIT) #define CHANGELESS (MDB_FIXEDMAP|MDB_NOSUBDIR|MDB_RDONLY| \ MDB_WRITEMAP|MDB_NOTLS|MDB_NOLOCK|MDB_NORDAHEAD) int mdb_env_get_flags(env, flags) LMDB::Env env unsigned int &flags = NO_INIT POSTCALL: flags &= (CHANGEABLE|CHANGELESS); OUTPUT: flags int mdb_env_get_path(env, path) LMDB::Env env const char * &path = NO_INIT OUTPUT: path int mdb_env_set_mapsize(env, size) LMDB::Env env size_t size POSTCALL: ProcError(RETVAL); int mdb_env_set_maxreaders(env, readers) LMDB::Env env unsigned int readers POSTCALL: ProcError(RETVAL); int mdb_env_get_maxreaders(env, readers) LMDB::Env env unsigned int &readers = NO_INIT OUTPUT: readers POSTCALL: ProcError(RETVAL); int mdb_env_set_maxdbs(env, dbs) LMDB::Env env int dbs POSTCALL: ProcError(RETVAL); int mdb_env_get_maxkeysize(env) LMDB::Env env UV mdb_env_id(env) LMDB::Env env CODE: RETVAL = PTR2UV(env); OUTPUT: RETVAL void _clone() CODE: MY_CXT_CLONE; MY_CXT.envid = NULL; MY_CXT.curdb = 0; MY_CXT.my_asv = get_sv("::a", GV_ADDMULTI); MY_CXT.my_bsv = get_sv("::b", GV_ADDMULTI); BOOT: MY_CXT_INIT; MY_CXT.my_asv = get_sv("::a", GV_ADDMULTI); MY_CXT.my_bsv = get_sv("::b", GV_ADDMULTI); MODULE = LMDB_File PACKAGE = LMDB::Txn PREFIX = mdb_txn int mdb_txn_begin(env, parent, flags, txn) LMDB::Env env TxnOrNull parent flags_t flags LMDB::Txn &txn = NO_INIT POSTCALL: ProcError(RETVAL); OUTPUT: txn UV mdb_txn_env(txn) LMDB::Txn txn CODE: RETVAL= PTR2UV(mdb_txn_env(txn)); OUTPUT: RETVAL int mdb_txn_commit(txn) LMDB::Txn txn POSTCALL: ProcError(RETVAL); void mdb_txn_abort(txn) LMDB::Txn txn void mdb_txn_reset(txn) LMDB::Txn txn int mdb_txn_renew(txn) LMDB::Txn txn POSTCALL: ProcError(RETVAL); UV mdb_txn_id(txn) LMDB::Txn txn CODE: RETVAL = PTR2UV(txn); OUTPUT: RETVAL MODULE = LMDB_File PACKAGE = LMDB::Txn PREFIX = mdb_txn_ #if MDB_VERSION_FULL > MDB_VERINT(0,9,14) size_t mdb_txn_id(txn) LMDB::Txn txn #endif MODULE = LMDB_File PACKAGE = LMDB::Txn PREFIX = mdb int mdb_dbi_open(txn, name, flags, dbi) LMDB::Txn txn const char * name = SvOK($arg) ? (const char *)SvPV_nolen($arg) : NULL; flags_t flags LMDB &dbi = NO_INIT PREINIT: dMY_CXT; POSTCALL: ProcError(RETVAL); mdb_dbi_flags(txn, dbi, &MY_CXT.cflags); MY_CXT.cflags |= LMDB_OFLAGS; MY_CXT.curdb = dbi; OUTPUT: dbi MODULE = LMDB_File PACKAGE = LMDB::Cursor PREFIX = mdb_cursor_ int mdb_cursor_open(txn, dbi, cursor) LMDB::Txn txn LMDB dbi LMDB::Cursor &cursor = NO_INIT OUTPUT: cursor void mdb_cursor_close(cursor) LMDB::Cursor cursor int mdb_cursor_count(cursor, count) LMDB::Cursor cursor UV &count = NO_INIT OUTPUT: count int mdb_cursor_dbi(cursor) LMDB::Cursor cursor int mdb_cursor_renew(txn, cursor) LMDB::Txn txn LMDB::Cursor cursor UV mdb_cursor_txn(cursor) LMDB::Cursor cursor CODE: RETVAL = PTR2UV(mdb_cursor_txn(cursor)); OUTPUT: RETVAL MODULE = LMDB_File PACKAGE = LMDB::Cursor PREFIX = mdb_cursor int mdb_cursor_get(cursor, key, data, op = MDB_NEXT) PREINIT: dMY_MULTICALL; dCURSOR; INPUT: LMDB::Cursor cursor +PREC_FLGS($var); DBKC &key DBD &data MDB_cursor_op op INIT: MY_PUSH_MULTICALL; POSTCALL: MY_POP_MULTICALL; ProcError(RETVAL); OUTPUT: key data int mdb_cursor_put(cursor, key, data, flags = 0, ...) PREINIT: dMY_MULTICALL; dCURSOR; INPUT: LMDB::Cursor cursor +PREC_FLGS($var); DBKC &key DBD &data = NO_INIT flags_t flags INIT: if(flags & MDB_RESERVE) { size_t res_size; size_t max_size = F_ISSET(MY_CXT.cflags, MDB_DUPSORT) ? mdb_env_get_maxkeysize(envid) : 0xffffffff; if(items != 5) croak("%s: MDB_RESERVE needs a length argument (1 .. %zu)", "LMDB_File::_put", max_size); res_size = SvUV(ST(5)); if(res_size == 0) croak("%s: MDB_RESERVE length must be > 0", "LMDB_File::_put"); if(ISDBDINT && res_size != sizeof(MyInt)) croak("%s: MDB_RESERVE with MDB_INTEGERDUP length should be %zu", "LMDB_File::_put", sizeof(MyInt)); if(res_size > max_size) croak("%s: MDB_RESERVE length should be <= %zu", "LMDB_File::_put", max_size); data.mv_size = res_size; data.mv_data = NULL; } else { /* Normal initialization */ Sv2DBD(ST(2), data); } MY_PUSH_MULTICALL; POSTCALL: MY_POP_MULTICALL; if((flags & MDB_NOOVERWRITE) && RETVAL == MDB_KEYEXIST) { sv_setstatic(aTHX_ aMY_CXT_ ST(2), &data, 0); SvSETMAGIC(ST(2)); } ProcError(RETVAL); if(flags & MDB_RESERVE) { sv_setstatic(aTHX_ aMY_CXT_ ST(2), &data, 1); SvSETMAGIC(ST(2)); } int mdb_cursor_del(cursor, flags = 0) PREINIT: dMY_MULTICALL; dCURSOR; INPUT: LMDB::Cursor cursor +PREC_FLGS($var); flags_t flags INIT: MY_PUSH_MULTICALL; POSTCALL: MY_POP_MULTICALL; ProcError(RETVAL); MODULE = LMDB_File PACKAGE = LMDB_File PREFIX = mdb #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif INCLUDE: const-xs.inc #ifdef __GNUC__ #pragma GCC diagnostic warning "-Wmaybe-uninitialized" #endif HV* mdb_stat(txn, dbi) LMDB::Txn txn LMDB dbi PREINIT: MDB_stat stat; CODE: populateStat(aTHX_ &RETVAL, mdb_stat(txn, dbi, &stat), &stat); OUTPUT: RETVAL int mdb_dbi_flags(txn, dbi, flags) LMDB::Txn txn LMDB dbi unsigned int &flags = NO_INIT POSTCALL: ProcError(RETVAL); OUTPUT: RETVAL flags void mdb_dbi_close(env, dbi) LMDB::Env env LMDB dbi int mdb_drop(txn, dbi, del) LMDB::Txn txn LMDB dbi int del POSTCALL: ProcError(RETVAL); =pod int mdb_set_compare(txn, dbi, cmp) LMDB::Txn txn LMDB dbi MDB_cmp_func * cmp int mdb_set_dupsort(txn, dbi, cmp) LMDB::Txn txn LMDB dbi MDB_cmp_func * cmp int mdb_set_relfunc(txn, dbi, rel) LMDB::Txn txn LMDB dbi MDB_rel_func * rel int mdb_set_relctx(txn, dbi, ctx) LMDB::Txn txn LMDB dbi void * ctx =cut int mdb_get(txn, dbi, key, data) PREINIT: dMY_MULTICALL; INPUT: LMDB::Txn txn +CHECK_ALLCUR; LMDB dbi DBK &key DBD &data = NO_INIT INIT: MY_PUSH_MULTICALL; POSTCALL: MY_POP_MULTICALL; ProcError(RETVAL); OUTPUT: data int mdb_put(txn, dbi, key, data, flags = 0, ...) PREINIT: dMY_MULTICALL; INPUT: LMDB::Txn txn +CHECK_ALLCUR; LMDB dbi DBK &key DBD &data = NO_INIT flags_t flags INIT: if(flags & MDB_RESERVE) { size_t res_size; size_t max_size = F_ISSET(MY_CXT.cflags, MDB_DUPSORT) ? mdb_env_get_maxkeysize(envid) : 0xffffffff; if(items != 6) croak("%s: MDB_RESERVE needs a length argument (1 .. %zu)", "LMDB_File::_put", max_size); res_size = SvUV(ST(5)); if(res_size == 0) croak("%s: MDB_RESERVE length must be > 0", "LMDB_File::_put"); if(ISDBDINT && res_size != sizeof(MyInt)) croak("%s: MDB_RESERVE with MDB_INTEGERDUP length should be %zu", "LMDB_File::_put", sizeof(MyInt)); if(res_size > max_size) croak("%s: MDB_RESERVE length should be <= %zu", "LMDB_File::_put", max_size); data.mv_size = res_size; data.mv_data = NULL; } else { /* Normal initialization */ Sv2DBD(ST(3), data); } MY_PUSH_MULTICALL; POSTCALL: MY_POP_MULTICALL; if((flags & MDB_NOOVERWRITE) && RETVAL == MDB_KEYEXIST) { sv_setstatic(aTHX_ aMY_CXT_ ST(3), &data, 0); SvSETMAGIC(ST(3)); } ProcError(RETVAL); if(flags & MDB_RESERVE) { sv_setstatic(aTHX_ aMY_CXT_ ST(3), &data, 1); SvSETMAGIC(ST(3)); } int mdb_del(txn, dbi, key, data) PREINIT: dMY_MULTICALL; INPUT: LMDB::Txn txn +CHECK_ALLCUR; LMDB dbi DBK &key DBD &data INIT: MY_PUSH_MULTICALL; CODE: RETVAL = mdb_del(txn, dbi, &key, (SvOK(ST(3)) ? &data : NULL)); MY_POP_MULTICALL; ProcError(RETVAL); OUTPUT: RETVAL int mdb_cmp(txn, dbi, a, b) PREINIT: dMY_MULTICALL; INPUT: LMDB::Txn txn +CHECK_ALLCUR; LMDB dbi DBD &a DBD &b INIT: MY_PUSH_MULTICALL; POSTCALL: MY_POP_MULTICALL; int mdb_dcmp(txn, dbi, a, b) PREINIT: dMY_MULTICALL; INPUT: LMDB::Txn txn +CHECK_ALLCUR; LMDB dbi DBD &a DBD &b INIT: MY_PUSH_MULTICALL; POSTCALL: MY_POP_MULTICALL; MODULE = LMDB_File PACKAGE = LMDB_File PREFIX = mdb_ =pod int mdb_reader_list(env, func, ctx) LMDB::Env env MDB_msg_func * func void * ctx =cut void _resetcurdbi() CODE: dMY_CXT; MY_CXT.curdb = 0; int mdb_reader_check(env, dead) LMDB::Env env int &dead OUTPUT: dead char * mdb_strerror(err) int err char * mdb_version(major, minor, patch) int &major = NO_INIT int &minor = NO_INIT int &patch = NO_INIT OUTPUT: major minor patch LMDB_File-0.13/Makefile.PL0000644000175600003110000001416613441552402013417 0ustar sogsoftuse 5.010000; use strict; use ExtUtils::MakeMaker; use Config; if($Config{archname} =~ /686/) { warn "liblmdb isn't supported in your platform, sorry.\n"; exit 0; } my $lmdb_dir = 'liblmdb/libraries/liblmdb'; my $LNAME = 'LMDB'; my $NAME = "${LNAME}_File"; my ($LIBS) = map { /^LIBS=(.*)$/ && $1 || () } @ARGV; my ($INC) = map { /^INC=(.*)/ && $1 || () } @ARGV; my $NOSYS = grep /\bNOSYSTEM\b/, @ARGV; my $myextlib = ''; { $LIBS ||= ''; my @libdata = ExtUtils::Liblist->ext($LIBS || '-llmdb', 0, 'mdb_env_create'); my @stdinc = qw(/usr/include /usr/local/include); push @stdinc, $libdata[3] if $libdata[3]; my($Head) = grep -f "$_/lmdb.h", @stdinc; if(!$NOSYS && ($INC || $Head) && $libdata[0]) { $INC ||= "-I$Head" if -f "$libdata[3]/lmdb.h"; warn "Will use SYSTEM lmdb in @{[$libdata[3] || $Head]}\n"; $LIBS ||= '-llmdb'; warn "If that path isn't a standard one, you may need to set LD_LIBRARY_PATH!\n" if($libdata[4][0] =~ /.so/); } elsif (eval { require Alien::LMDB }) { my $alien = Alien::LMDB->new; $INC = $alien->cflags; $LIBS = $alien->libs; warn "Using Alien::LMDB (" . $alien->install_type . "): " . $alien->dist_dir . "\n"; } else { unless(-e "$lmdb_dir/Makefile") { warn "Clone lmdb from its repo and put a copy/link in 'liblmdb' directory"; exit 0; } $myextlib = "$lmdb_dir/liblmdb\$(LIB_EXT)"; } $LIBS .= ' -lrt' if $^O =~ /solaris/i; if($myextlib) { #lmdb's Makefile needs care if($^O =~ /MSWin32|freebsd/i) { if($ENV{AUTOMATED_TESTING}) { warn "Can't build liblmdb in $^O without human help, sorry\n"; } else { warn "Please install a recent version of liblmdb or try to build the included one.\n"; } exit 0; } warn "Will try to build and use my included copy of liblmdb.\n"; } if($^O =~ /MSWin32/) { } else { #LMDB needs pthread, so perl needs to be linked with. unless ($Config{perllibs} =~ 'pthread') { warn "LMDB_File needs a perl linked with 'pthread'.\n" . "The module will be build, but can't be loaded\n" . "without proper initialization.\n(See perl #122906)\n"; $LIBS .= ' -lpthread'; } } } WriteMakefile( NAME => $NAME, MIN_PERL_VERSION => '5.10.0', CONFIGURE_REQUIRES => { 'ExtUtils::MakeMaker' => '6.64' }, VERSION_FROM => "lib/$NAME.pm", # finds $VERSION PREREQ_PM => {}, # e.g., Module::Name => 1.1 ABSTRACT_FROM => "lib/$NAME.pm", # retrieve abstract from module AUTHOR => 'Salvador Ortiz ', DEFINE => '', # e.g., '-DHAVE_SOMETHING' XSPROTOARG => '-noprototypes', LICENSE => 'artistic_2', META_MERGE => { "meta-spec" => { version => 2 }, resources => { repository => { type => 'git', url => 'git://github.com/salortiz/LMDB_File.git', web => 'https://github.com/salortiz/LMDB_File', } } }, TEST_REQUIRES => { 'Test::More' => 0, 'Test::Exception' => 0, #'Test::ZeroCopy' => 0 Dependency chain broken in String::Slice }, OBJECT => '$(O_FILES)', # link all the C files too LIBS => $LIBS, ($myextlib ? ( MYEXTLIB => $myextlib, INC => "-I$lmdb_dir", ) : ( INC => $INC ) ), realclean => { FILES => 'const-*.inc' } ); if (eval {require ExtUtils::Constant; 1}) { # If you edit these definitions to change the constants used by this module, # you will need to use the generated const-c.inc and const-xs.inc # files to replace their "fallback" counterparts before distributing your # changes. my @names = ( qw(MDB_APPEND MDB_APPENDDUP MDB_BAD_RSLOT MDB_BAD_DBI MDB_BAD_TXN MDB_BAD_VALSIZE MDB_CP_COMPACT MDB_CORRUPTED MDB_CREATE MDB_CURRENT MDB_CURSOR_FULL MDB_DBS_FULL MDB_DUPFIXED MDB_DUPSORT MDB_FIXEDMAP MDB_INCOMPATIBLE MDB_INTEGERDUP MDB_INTEGERKEY MDB_INVALID MDB_KEYEXIST MDB_LAST_ERRCODE MDB_MAPASYNC MDB_MAP_FULL MDB_MAP_RESIZED MDB_MULTIPLE MDB_NODUPDATA MDB_NOLOCK MDB_NOMEMINIT MDB_NOMETASYNC MDB_NOOVERWRITE MDB_NORDAHEAD MDB_NOSUBDIR MDB_NOSYNC MDB_NOTFOUND MDB_NOTLS MDB_PAGE_FULL MDB_PAGE_NOTFOUND MDB_PANIC MDB_RDONLY MDB_READERS_FULL MDB_RESERVE MDB_REVERSEDUP MDB_REVERSEKEY MDB_SUCCESS MDB_TLS_FULL MDB_TXN_FULL MDB_VERSION_FULL MDB_VERSION_MAJOR MDB_VERSION_MINOR MDB_VERSION_MISMATCH MDB_VERSION_PATCH MDB_WRITEMAP), # My own qw(LMDB_OFLAGN), {name=>"MDB_VERSION_STRING", type=>"PV", macro=>"1"}, {name=>"MDB_VERSION_DATE", type=>"PV", macro=>"1"}, {name=>"MDB_FIRST", macro=>"1"}, {name=>"MDB_FIRST_DUP", macro=>"1"}, {name=>"MDB_GET_BOTH", macro=>"1"}, {name=>"MDB_GET_BOTH_RANGE", macro=>"1"}, {name=>"MDB_GET_CURRENT", macro=>"1"}, {name=>"MDB_GET_MULTIPLE", macro=>"1"}, {name=>"MDB_LAST", macro=>"1"}, {name=>"MDB_LAST_DUP", macro=>"1"}, {name=>"MDB_NEXT", macro=>"1"}, {name=>"MDB_NEXT_DUP", macro=>"1"}, {name=>"MDB_NEXT_MULTIPLE", macro=>"1"}, {name=>"MDB_NEXT_NODUP", macro=>"1"}, {name=>"MDB_PREV", macro=>"1"}, {name=>"MDB_PREV_DUP", macro=>"1"}, {name=>"MDB_PREV_NODUP", macro=>"1"}, {name=>"MDB_SET", macro=>"1"}, {name=>"MDB_SET_KEY", macro=>"1"}, {name=>"MDB_SET_RANGE", macro=>"1"} ); ExtUtils::Constant::WriteConstants( NAME => $NAME, NAMES => \@names, DEFAULT_TYPE => 'IV', C_FILE => 'const-c.inc', XS_FILE => 'const-xs.inc', ); } else { use File::Copy; use File::Spec; foreach my $file ('const-c.inc', 'const-xs.inc') { my $fallback = File::Spec->catfile('fallback', $file); copy ($fallback, $file) or die "Can't copy $fallback to $file: $!"; } } sub MY::postamble { if($myextlib) { if ($^O =~ /MSWin32/ && !defined($ENV{SYSTEMROOT})) { if ($Config{'make'} =~ /dmake/i) { return <<'EOT'; $(MYEXTLIB): liblmdb/Makefile @[ cd liblmdb/libraries/liblmdb $(MAKE) XCFLAGS=-fPIC liblmdb$(LIB_EXT) cd .. ] EOT } elsif ($Config{'make'} =~ /nmake/i) { return <<'EOT'; $(MYEXTLIB): liblmdb/Makefile cd liblmdb/libraries/liblmdb $(MAKE) XCFLAGS=-fPIC liblmdb$(LIB_EXT) cd .. EOT } } else { return <<'EOT'; $(MYEXTLIB): liblmdb/libraries/liblmdb/Makefile cd liblmdb/libraries/liblmdb && $(MAKE) XCFLAGS=-fPIC liblmdb$(LIB_EXT) EOT } } }