Skip to content

Commit

Permalink
Prepare release v0.13
Browse files Browse the repository at this point in the history
- Fix for hidden Perl_do_getvec in 5.38
Solves #37 and rt.cpan.org 148421
  • Loading branch information
salortiz committed Sep 2, 2023
1 parent 487c7f5 commit cbd7deb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Revision history for Perl extension LMDB_File.
0.13 Sat Sep 02 2023
- Fix for hidden Perl_do_vecget in 5.28
Thanks to Niko Tyni <[email protected]> for the patch

0.12 Wed Jan 25 2017
- Conditionally compile mdb_txn_id support.
- Updated README
Expand Down
45 changes: 44 additions & 1 deletion LMDB.xs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,49 @@ S_mySvPVutf8(pTHX_ SV *sv, STRLEN *const len) {

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)
{
Expand Down Expand Up @@ -152,7 +195,7 @@ typedef struct {

START_MY_CXT

#define LMDB_OFLAGS TOHIWORD(Perl_do_vecget(aTHX_ MY_CXT.OFlags, dbi, LMDB_OFLAGN))
#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)

Expand Down
6 changes: 3 additions & 3 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LMDB_File version 0.12
LMDB_File version 0.13
======================

LMDB_File is a Perl wrapper around the OpenLDAP's LMDB (Lightning
Expand All @@ -18,7 +18,7 @@ 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 or greater linked with pthreads.
* 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.
Expand Down Expand Up @@ -66,7 +66,7 @@ be aware that the API isn't in stone yet. See TODO

COPYRIGHT AND LICENCE

Copyright (C) 2013-2021 by Salvador Ortiz Garcia
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.
Expand Down
2 changes: 1 addition & 1 deletion lib/LMDB_File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use Carp;
require Exporter;
use AutoLoader;

our $VERSION = '0.12';
our $VERSION = '0.13';
our $DEBUG = 0;

our @ISA = qw(Exporter);
Expand Down

0 comments on commit cbd7deb

Please sign in to comment.