Front page | perl.perl5.porters |
Postings from July 2012
[PATCH] make array interface 64-bit safe by using IV instead of I32
Thread Next
From:
Rev. Chip
Date:
July 12, 2012 23:37
Subject:
[PATCH] make array interface 64-bit safe by using IV instead of I32
Message ID:
20120713063651.GA26681@tytlal.tinsaucer.com
I guess I'm crazy, because making the array interface 64-bit safe seemed
like a good thing to do tonight. I pushed it to camel as the "chip/aviv"
branch, diff is attached, all tests pass, yada yada.
I think this is mergeable. Opinions to the contrary are invited.
commit 4e24ddcfb3464e86277001195072002f7eb215ea
Author: Chip Salzenberg <chip@pobox.com>
Date: Thu Jul 12 23:32:40 2012 -0700
Make the array interface 64-bit safe by using IV instead of I32 for array indices.
diff --git a/av.c b/av.c
index 0551668..c96e865 100644
--- a/av.c
+++ b/av.c
@@ -27,7 +27,7 @@ void
Perl_av_reify(pTHX_ AV *av)
{
dVAR;
- I32 key;
+ IV key;
PERL_ARGS_ASSERT_AV_REIFY;
assert(SvTYPE(av) == SVt_PVAV);
@@ -64,7 +64,7 @@ extended.
*/
void
-Perl_av_extend(pTHX_ AV *av, I32 key)
+Perl_av_extend(pTHX_ AV *av, IV key)
{
dVAR;
MAGIC *mg;
@@ -82,8 +82,7 @@ Perl_av_extend(pTHX_ AV *av, I32 key)
}
if (key > AvMAX(av)) {
SV** ary;
- I32 tmp;
- I32 newmax;
+ IV tmp, newmax;
if (AvALLOC(av) != AvARRAY(av)) {
ary = AvALLOC(av) + AvFILLp(av) + 1;
@@ -200,7 +199,7 @@ The rough perl equivalent is C<$myarray[$idx]>.
*/
SV**
-Perl_av_fetch(pTHX_ register AV *av, I32 key, I32 lval)
+Perl_av_fetch(pTHX_ register AV *av, IV key, I32 lval)
{
dVAR;
@@ -286,7 +285,7 @@ more information on how to use this function on tied arrays.
*/
SV**
-Perl_av_store(pTHX_ register AV *av, I32 key, SV *val)
+Perl_av_store(pTHX_ register AV *av, IV key, SV *val)
{
dVAR;
SV** ary;
@@ -387,7 +386,7 @@ Perl equivalent: C<my @new_array = ($scalar1, $scalar2, $scalar3...);>
*/
AV *
-Perl_av_make(pTHX_ register I32 size, register SV **strp)
+Perl_av_make(pTHX_ IV size, SV **strp)
{
register AV * const av = MUTABLE_AV(newSV_type(SVt_PVAV));
/* sv_upgrade does AvREAL_only() */
@@ -396,7 +395,7 @@ Perl_av_make(pTHX_ register I32 size, register SV **strp)
if (size) { /* "defined" was returning undef for size==0 anyway. */
register SV** ary;
- register I32 i;
+ register IV i;
Newx(ary,size,SV*);
AvALLOC(av) = ary;
AvARRAY(av) = ary;
@@ -433,7 +432,7 @@ void
Perl_av_clear(pTHX_ register AV *av)
{
dVAR;
- I32 extra;
+ IV extra;
bool real;
PERL_ARGS_ASSERT_AV_CLEAR;
@@ -462,7 +461,7 @@ Perl_av_clear(pTHX_ register AV *av)
if ((real = !!AvREAL(av))) {
SV** const ary = AvARRAY(av);
- I32 index = AvFILLp(av) + 1;
+ IV index = AvFILLp(av) + 1;
ENTER;
SAVEFREESV(SvREFCNT_inc_simple_NN(av));
while (index) {
@@ -505,7 +504,7 @@ Perl_av_undef(pTHX_ register AV *av)
av_fill(av, -1);
if ((real = !!AvREAL(av))) {
- register I32 key = AvFILLp(av) + 1;
+ register IV key = AvFILLp(av) + 1;
ENTER;
SAVEFREESV(SvREFCNT_inc_simple_NN(av));
while (key)
@@ -645,10 +644,10 @@ Perl equivalent: C<unshift @myarray, ( (undef) x $n );>
*/
void
-Perl_av_unshift(pTHX_ register AV *av, register I32 num)
+Perl_av_unshift(pTHX_ register AV *av, register IV num)
{
dVAR;
- register I32 i;
+ register IV i;
MAGIC* mg;
PERL_ARGS_ASSERT_AV_UNSHIFT;
@@ -679,9 +678,9 @@ Perl_av_unshift(pTHX_ register AV *av, register I32 num)
}
if (num) {
register SV **ary;
- const I32 i = AvFILLp(av);
+ const IV i = AvFILLp(av);
/* Create extra elements */
- const I32 slide = i > 0 ? i : 0;
+ const IV slide = i > 0 ? i : 0;
num += slide;
av_extend(av, i + num);
AvFILLp(av) += num;
@@ -751,7 +750,7 @@ The Perl equivalent for this is C<$#myarray>.
=cut
*/
-I32
+IV
Perl_av_len(pTHX_ AV *av)
{
PERL_ARGS_ASSERT_AV_LEN;
@@ -775,7 +774,7 @@ the same as C<av_clear(av)>.
=cut
*/
void
-Perl_av_fill(pTHX_ register AV *av, I32 fill)
+Perl_av_fill(pTHX_ register AV *av, IV fill)
{
dVAR;
MAGIC *mg;
@@ -793,7 +792,7 @@ Perl_av_fill(pTHX_ register AV *av, I32 fill)
return;
}
if (fill <= AvMAX(av)) {
- I32 key = AvFILLp(av);
+ IV key = AvFILLp(av);
SV** const ary = AvARRAY(av);
if (AvREAL(av)) {
@@ -827,7 +826,7 @@ C<G_DISCARD> version.
=cut
*/
SV *
-Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags)
+Perl_av_delete(pTHX_ AV *av, IV key, I32 flags)
{
dVAR;
SV *sv;
@@ -919,7 +918,7 @@ Perl equivalent: C<exists($myarray[$key])>.
=cut
*/
bool
-Perl_av_exists(pTHX_ AV *av, I32 key)
+Perl_av_exists(pTHX_ AV *av, IV key)
{
dVAR;
PERL_ARGS_ASSERT_AV_EXISTS;
diff --git a/cpan/List-Util/multicall.h b/cpan/List-Util/multicall.h
index b8296e1..dc614a7 100644
--- a/cpan/List-Util/multicall.h
+++ b/cpan/List-Util/multicall.h
@@ -39,8 +39,8 @@ multicall_pad_push(pTHX_ AV *padlist, int depth)
SV** const svp = AvARRAY(padlist);
AV* const newpad = newAV();
SV** const oldpad = AvARRAY(svp[depth-1]);
- I32 ix = AvFILLp((AV*)svp[1]);
- const I32 names_fill = AvFILLp((AV*)svp[0]);
+ IV ix = AvFILLp((AV*)svp[1]);
+ const IV names_fill = AvFILLp((AV*)svp[0]);
SV** const names = AvARRAY(svp[0]);
AV *av;
diff --git a/cpan/Unicode-Collate/Collate.xs b/cpan/Unicode-Collate/Collate.xs
index e35d724..3b7c9a2 100644
--- a/cpan/Unicode-Collate/Collate.xs
+++ b/cpan/Unicode-Collate/Collate.xs
@@ -413,7 +413,7 @@ mk_SortKey (self, buf)
AV *bufAV;
HV *selfHV;
UV back_flag;
- I32 i, buf_len;
+ IV i, buf_len;
IV lv, level, uca_vers;
bool upper_lower, kata_hira, v2i, last_is_var;
CODE:
diff --git a/dist/Data-Dumper/Dumper.pm b/dist/Data-Dumper/Dumper.pm
index a099277..d758034 100644
--- a/dist/Data-Dumper/Dumper.pm
+++ b/dist/Data-Dumper/Dumper.pm
@@ -10,7 +10,7 @@
package Data::Dumper;
BEGIN {
- $VERSION = '2.135_06'; # Don't forget to set version and release
+ $VERSION = '2.135_07'; # Don't forget to set version and release
} # date in POD!
#$| = 1;
@@ -1332,7 +1332,7 @@ modify it under the same terms as Perl itself.
=head1 VERSION
-Version 2.135_06 (March 20 2012)
+Version 2.135_07 (July 12 2012)
=head1 SEE ALSO
diff --git a/dist/Data-Dumper/Dumper.xs b/dist/Data-Dumper/Dumper.xs
index 91e4c6c..c382c97 100644
--- a/dist/Data-Dumper/Dumper.xs
+++ b/dist/Data-Dumper/Dumper.xs
@@ -270,7 +270,7 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
I32 deepcopy, I32 quotekeys, SV *bless, I32 maxdepth, SV *sortkeys)
{
char tmpbuf[128];
- U32 i;
+ Size_t i;
char *c, *r, *realpack;
#ifdef DD_USE_OLD_ID_FORMAT
char id[128];
@@ -518,8 +518,8 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
}
else if (realtype == SVt_PVAV) {
SV *totpad;
- I32 ix = 0;
- const I32 ixmax = av_len((AV *)ival);
+ IV ix = 0;
+ const IV ixmax = av_len((AV *)ival);
SV * const ixsv = newSViv(0);
/* allowing for a 24 char wide array index */
@@ -696,7 +696,7 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
bool do_utf8 = FALSE;
if (sortkeys) {
- if (!(keys && (I32)i <= av_len(keys))) break;
+ if (!(keys && (IV)i <= av_len(keys))) break;
} else {
if (!(entry = hv_iternext((HV *)ival))) break;
}
@@ -1070,7 +1070,8 @@ Data_Dumper_Dumpxs(href, ...)
HV *seenhv = NULL;
AV *postav, *todumpav, *namesav;
I32 level = 0;
- I32 indent, terse, i, imax, postlen;
+ I32 indent, terse;
+ IV i, imax, postlen;
SV **svp;
SV *val, *name, *pad, *xpad, *apad, *sep, *pair, *varname;
SV *freezer, *toaster, *bless, *sortkeys;
@@ -1252,7 +1253,7 @@ Data_Dumper_Dumpxs(href, ...)
sv_catsv(retval, valstr);
sv_catsv(retval, sep);
if (postlen >= 0) {
- I32 i;
+ IV i;
sv_catsv(retval, pad);
for (i = 0; i <= postlen; ++i) {
SV *elem;
diff --git a/dist/ExtUtils-ParseXS/lib/perlxstut.pod b/dist/ExtUtils-ParseXS/lib/perlxstut.pod
index 93c1bfb..7790e39 100644
--- a/dist/ExtUtils-ParseXS/lib/perlxstut.pod
+++ b/dist/ExtUtils-ParseXS/lib/perlxstut.pod
@@ -1088,7 +1088,7 @@ Mytest.xs:
SV * paths
INIT:
AV * results;
- I32 numpaths = 0;
+ IV numpaths = 0;
int i, n;
struct statfs buf;
diff --git a/dist/Math-BigInt-FastCalc/FastCalc.xs b/dist/Math-BigInt-FastCalc/FastCalc.xs
index a8247c9..dc33f50 100644
--- a/dist/Math-BigInt-FastCalc/FastCalc.xs
+++ b/dist/Math-BigInt-FastCalc/FastCalc.xs
@@ -108,7 +108,7 @@ _copy(class, x)
INIT:
AV* a;
AV* a2;
- I32 elems;
+ IV elems;
CODE:
a = (AV*)SvRV(x); /* ref to aray, don't check ref */
@@ -144,8 +144,8 @@ __strip_zeros(x)
INIT:
AV* a;
SV* temp;
- I32 elems;
- I32 index;
+ IV elems;
+ IV index;
CODE:
a = (AV*)SvRV(x); /* ref to aray, don't check ref */
@@ -189,8 +189,8 @@ _dec(class,x)
INIT:
AV* a;
SV* temp;
- I32 elems;
- I32 index;
+ IV elems;
+ IV index;
NV MAX;
CODE:
@@ -233,8 +233,8 @@ _inc(class,x)
INIT:
AV* a;
SV* temp;
- I32 elems;
- I32 index;
+ IV elems;
+ IV index;
NV BASE;
CODE:
@@ -347,13 +347,13 @@ _acmp(class, cx, cy);
INIT:
AV* array_x;
AV* array_y;
- I32 elemsx, elemsy, diff;
+ IV elemsx, elemsy, diff;
SV* tempx;
SV* tempy;
STRLEN lenx;
STRLEN leny;
NV diff_nv;
- I32 diff_str;
+ IV diff_str;
CODE:
array_x = (AV*)SvRV(cx); /* ref to aray, don't check ref */
@@ -376,7 +376,7 @@ _acmp(class, cx, cy);
tempy = *av_fetch(array_y, elemsx, 0); /* fetch last element */
SvPV(tempx, lenx); /* convert to string & store length */
SvPV(tempy, leny); /* convert to string & store length */
- diff_str = (I32)lenx - (I32)leny;
+ diff_str = (IV)lenx - (IV)leny;
if (diff_str > 0)
{
RETURN_MORTAL_INT(1); /* same len, but first elems differs in len */
diff --git a/dist/Math-BigInt-FastCalc/lib/Math/BigInt/FastCalc.pm b/dist/Math-BigInt-FastCalc/lib/Math/BigInt/FastCalc.pm
index 81f29a1..9bf5a60 100644
--- a/dist/Math-BigInt-FastCalc/lib/Math/BigInt/FastCalc.pm
+++ b/dist/Math-BigInt-FastCalc/lib/Math/BigInt/FastCalc.pm
@@ -8,7 +8,7 @@ use Math::BigInt::Calc 1.997;
use vars '$VERSION';
-$VERSION = '0.30';
+$VERSION = '0.31';
##############################################################################
# global constants, flags and accessory
diff --git a/dump.c b/dump.c
index ad3b960..cd9a99a 100644
--- a/dump.c
+++ b/dump.c
@@ -1679,7 +1679,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
Perl_dump_indent(aTHX_ level, file, " FLAGS = (%s)\n",
SvCUR(d) ? SvPVX_const(d) + 1 : "");
if (nest < maxnest && av_len(MUTABLE_AV(sv)) >= 0) {
- int count;
+ IV count;
for (count = 0; count <= av_len(MUTABLE_AV(sv)) && count < maxnest; count++) {
SV** const elt = av_fetch(MUTABLE_AV(sv),count,0);
diff --git a/embed.fnc b/embed.fnc
index eb81d9c..2e4fbe7 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -190,23 +190,23 @@ Apd |OP* |op_prepend_elem|I32 optype|NULLOK OP* first|NULLOK OP* last
p |I32 |apply |I32 type|NN SV** mark|NN SV** sp
ApM |void |apply_attrs_string|NN const char *stashpv|NN CV *cv|NN const char *attrstr|STRLEN len
Apd |void |av_clear |NN AV *av
-Apd |SV* |av_delete |NN AV *av|I32 key|I32 flags
-ApdR |bool |av_exists |NN AV *av|I32 key
-Apd |void |av_extend |NN AV *av|I32 key
-ApdR |SV** |av_fetch |NN AV *av|I32 key|I32 lval
-Apd |void |av_fill |NN AV *av|I32 fill
-ApdR |I32 |av_len |NN AV *av
-ApdR |AV* |av_make |I32 size|NN SV **strp
+Apd |SV* |av_delete |NN AV *av|IV key|I32 flags
+ApdR |bool |av_exists |NN AV *av|IV key
+Apd |void |av_extend |NN AV *av|IV key
+ApdR |SV** |av_fetch |NN AV *av|IV key|I32 lval
+Apd |void |av_fill |NN AV *av|IV fill
+ApdR |IV|av_len |NN AV *av
+ApdR |AV* |av_make |IV size|NN SV **strp
Apd |SV* |av_pop |NN AV *av
ApdoxM |void |av_create_and_push|NN AV **const avp|NN SV *const val
Apd |void |av_push |NN AV *av|NN SV *val
: Used in scope.c, and by Data::Alias
EXp |void |av_reify |NN AV *av
ApdR |SV* |av_shift |NN AV *av
-Apd |SV** |av_store |NN AV *av|I32 key|NULLOK SV *val
+Apd |SV** |av_store |NN AV *av|IV key|NULLOK SV *val
Apd |void |av_undef |NN AV *av
ApdoxM |SV** |av_create_and_unshift_one|NN AV **const avp|NN SV *const val
-Apd |void |av_unshift |NN AV *av|I32 num
+Apd |void |av_unshift |NN AV *av|IV num
Apo |SV** |av_arylen_p |NN AV *av
Apo |IV* |av_iter_p |NN AV *av
#if defined(PERL_IN_AV_C)
@@ -1138,8 +1138,8 @@ Apda |char* |savesharedsvpv |NN SV *sv
Apda |char* |savesvpv |NN SV* sv
Ap |void |savestack_grow
Ap |void |savestack_grow_cnt |I32 need
-Amp |void |save_aelem |NN AV* av|I32 idx|NN SV **sptr
-Ap |void |save_aelem_flags|NN AV* av|I32 idx|NN SV **sptr|const U32 flags
+Amp |void |save_aelem |NN AV* av|IV idx|NN SV **sptr
+Ap |void |save_aelem_flags|NN AV* av|IV idx|NN SV **sptr|const U32 flags
Ap |I32 |save_alloc |I32 size|I32 pad
Ap |void |save_aptr |NN AV** aptr
Ap |AV* |save_ary |NN GV* gv
@@ -1147,7 +1147,7 @@ Ap |void |save_bool |NN bool* boolp
Ap |void |save_clearsv |NN SV** svp
Ap |void |save_delete |NN HV *hv|NN char *key|I32 klen
Ap |void |save_hdelete |NN HV *hv|NN SV *keysv
-Ap |void |save_adelete |NN AV *av|I32 key
+Ap |void |save_adelete |NN AV *av|IV key
Ap |void |save_destructor|DESTRUCTORFUNC_NOCONTEXT_t f|NN void* p
Ap |void |save_destructor_x|DESTRUCTORFUNC_t f|NULLOK void* p
Apmb |void |save_freesv |NULLOK SV* sv
@@ -1184,12 +1184,15 @@ Ap |void |save_sptr |NN SV** sptr
Ap |SV* |save_svref |NN SV** sptr
Ap |void |save_pushptr |NULLOK void *const ptr|const int type
Ap |void |save_pushi32ptr|const I32 i|NULLOK void *const ptr|const int type
+Ap |void |save_pushivptr |const IV i|NULLOK void *const ptr|const int type
: Used by SAVESWITCHSTACK() in pp.c
Ap |void |save_pushptrptr|NULLOK void *const ptr1 \
|NULLOK void *const ptr2|const int type
#if defined(PERL_IN_SCOPE_C)
s |void |save_pushptri32ptr|NULLOK void *const ptr1|const I32 i \
|NULLOK void *const ptr2|const int type
+s |void |save_pushptrivptr|NULLOK void *const ptr1|const IV i \
+ |NULLOK void *const ptr2|const int type
#endif
: Used in perly.y
p |OP* |sawparens |NULLOK OP* o
diff --git a/embed.h b/embed.h
index 5dca8e3..1e2c098 100644
--- a/embed.h
+++ b/embed.h
@@ -498,6 +498,7 @@
#define save_padsv_and_mortalize(a) Perl_save_padsv_and_mortalize(aTHX_ a)
#define save_pptr(a) Perl_save_pptr(aTHX_ a)
#define save_pushi32ptr(a,b,c) Perl_save_pushi32ptr(aTHX_ a,b,c)
+#define save_pushivptr(a,b,c) Perl_save_pushivptr(aTHX_ a,b,c)
#define save_pushptr(a,b) Perl_save_pushptr(aTHX_ a,b)
#define save_pushptrptr(a,b,c) Perl_save_pushptrptr(aTHX_ a,b,c)
#define save_re_context() Perl_save_re_context(aTHX)
@@ -1529,6 +1530,7 @@
# endif
# if defined(PERL_IN_SCOPE_C)
#define save_pushptri32ptr(a,b,c,d) S_save_pushptri32ptr(aTHX_ a,b,c,d)
+#define save_pushptrivptr(a,b,c,d) S_save_pushptrivptr(aTHX_ a,b,c,d)
#define save_scalar_at(a,b) S_save_scalar_at(aTHX_ a,b)
# endif
# if defined(PERL_IN_SV_C)
diff --git a/ext/Hash-Util-FieldHash/FieldHash.xs b/ext/Hash-Util-FieldHash/FieldHash.xs
index e726041..2e003bb 100644
--- a/ext/Hash-Util-FieldHash/FieldHash.xs
+++ b/ext/Hash-Util-FieldHash/FieldHash.xs
@@ -321,7 +321,7 @@ HUF_fix_trigger(pTHX_ SV *trigger, SV *new_id) {
void
HUF_fix_objects(pTHX) {
dMY_CXT;
- I32 i, len;
+ IV i, len;
HE* ent;
AV* oblist = (AV*)sv_2mortal((SV*)newAV());
hv_iterinit(MY_CXT.ob_reg);
diff --git a/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm b/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm
index 4f833ff..5ba522f 100644
--- a/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm
+++ b/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Scalar::Util qw( reftype);
-our $VERSION = '1.10';
+our $VERSION = '1.11';
require Exporter;
our @ISA = qw(Exporter);
diff --git a/ext/XS-APItest/APItest.pm b/ext/XS-APItest/APItest.pm
index 929bf49..a72fb6c 100644
--- a/ext/XS-APItest/APItest.pm
+++ b/ext/XS-APItest/APItest.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Carp;
-our $VERSION = '0.41';
+our $VERSION = '0.42';
require XSLoader;
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index 1685948..0e0b174 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -271,7 +271,7 @@ blockhook_csc_start(pTHX_ int full)
SAVEGENERICSV(GvAV(MY_CXT.cscgv));
if (cur) {
- I32 i;
+ IV i;
AV *const new_av = newAV();
for (i = 0; i <= av_len(cur); i++) {
@@ -3285,7 +3285,7 @@ SV*
fetch_pad_names( cv )
CV* cv
PREINIT:
- I32 i;
+ IV i;
AV *pad_namelist;
AV *retav = newAV();
CODE:
diff --git a/ext/mro/mro.pm b/ext/mro/mro.pm
index 31f5ce6..4b29d6b 100644
--- a/ext/mro/mro.pm
+++ b/ext/mro/mro.pm
@@ -12,7 +12,7 @@ use warnings;
# mro.pm versions < 1.00 reserved for MRO::Compat
# for partial back-compat to 5.[68].x
-our $VERSION = '1.09';
+our $VERSION = '1.10';
sub import {
mro::set_mro(scalar(caller), $_[1]) if $_[1];
diff --git a/ext/mro/mro.xs b/ext/mro/mro.xs
index 7b5a86d..f7b7480 100644
--- a/ext/mro/mro.xs
+++ b/ext/mro/mro.xs
@@ -251,7 +251,7 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, U32 level)
hierarchy is not C3-incompatible */
if(!winner) {
SV *errmsg;
- I32 i;
+ IV i;
errmsg = newSVpvf(
"Inconsistent hierarchy during C3 merge of class '%"SVf"':\n\t"
diff --git a/handy.h b/handy.h
index 2205742..928e422 100644
--- a/handy.h
+++ b/handy.h
@@ -1134,16 +1134,22 @@ PoisonWith(0xEF) for catching access to freed memory.
#define MEM_SIZE_MAX ((MEM_SIZE)~0)
-/* The +0.0 in MEM_WRAP_CHECK_ is an attempt to foil
- * overly eager compilers that will bleat about e.g.
- * (U16)n > (size_t)~0/sizeof(U16) always being false. */
#ifdef PERL_MALLOC_WRAP
#define MEM_WRAP_CHECK(n,t) MEM_WRAP_CHECK_1(n,t,PL_memory_wrap)
-#define MEM_WRAP_CHECK_1(n,t,a) \
- (void)(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > MEM_SIZE_MAX/sizeof(t) && (Perl_croak_nocontext("%s",(a)),0))
+
+/* The GCC expression block and the alternative +0.0 are an attempt to foil
+ * overly eager compilers that will bleat about e.g.
+ * (U16)n > (size_t)~0/sizeof(U16) always being false. */
+#if defined(__GNUC__)
+# define MEM_WRAP_CHECK_1(n,t,a) \
+ (void)({ UV _n = (n); if (_n > MEM_SIZE_MAX/sizeof(t)) Perl_croak_nocontext("%s",(a)); 0; })
+#else
+# define MEM_WRAP_CHECK_1(n,t,a) \
+ (void)((UV)(n)+0.0 > MEM_SIZE_MAX/sizeof(t) && (Perl_croak_nocontext("%s",(a)),0))
+#endif
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
-#define PERL_STRLEN_ROUNDUP(n) ((void)(((n) > MEM_SIZE_MAX - 2 * PERL_STRLEN_ROUNDUP_QUANTUM) ? (Perl_croak_nocontext("%s",PL_memory_wrap),0):0),((n-1+PERL_STRLEN_ROUNDUP_QUANTUM)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1)))
+#define PERL_STRLEN_ROUNDUP(n) ((void)(((UV)(n) > MEM_SIZE_MAX - 2 * PERL_STRLEN_ROUNDUP_QUANTUM) ? (Perl_croak_nocontext("%s",PL_memory_wrap),0):0),((n-1+PERL_STRLEN_ROUNDUP_QUANTUM)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1)))
#else
diff --git a/op.c b/op.c
index e722b89..3924fdd 100644
--- a/op.c
+++ b/op.c
@@ -5601,7 +5601,7 @@ Perl_newSTATEOP(pTHX_ I32 flags, char *label, OP *o)
/* this line can have a breakpoint - store the cop in IV */
AV *av = CopFILEAVx(PL_curcop);
if (av) {
- SV * const * const svp = av_fetch(av, (I32)CopLINE(cop), FALSE);
+ SV * const * const svp = av_fetch(av, CopLINE(cop), FALSE);
if (svp && *svp != &PL_sv_undef ) {
(void)SvIOK_on(*svp);
SvIV_set(*svp, PTR2IV(cop));
diff --git a/op.h b/op.h
index ff2a540..9412bbf 100644
--- a/op.h
+++ b/op.h
@@ -852,7 +852,7 @@ preprocessing token; the type of I<arg> depends on I<which>.
#define CALL_BLOCK_HOOKS(which, arg) \
STMT_START { \
if (PL_blockhooks) { \
- I32 i; \
+ IV i; \
for (i = av_len(PL_blockhooks); i >= 0; i--) { \
SV *sv = AvARRAY(PL_blockhooks)[i]; \
BHK *hk; \
diff --git a/perl.c b/perl.c
index a4a05f5..9b52222 100644
--- a/perl.c
+++ b/perl.c
@@ -4679,9 +4679,9 @@ S_incpush(pTHX_ const char *const dir, STRLEN len, U32 flags)
/* finally add this lib directory at the end of @INC */
if (unshift) {
#ifdef PERL_IS_MINIPERL
- const U32 extra = 0;
+ const Size_t extra = 0;
#else
- U32 extra = av_len(av) + 1;
+ Size_t extra = av_len(av) + 1;
#endif
av_unshift(inc, extra + push_basedir);
if (push_basedir)
diff --git a/pod/perlembed.pod b/pod/perlembed.pod
index e40035e..0787a69 100644
--- a/pod/perlembed.pod
+++ b/pod/perlembed.pod
@@ -481,7 +481,7 @@ been wrapped here):
I32 matches(SV *string, char *pattern, AV **match_list)
{
SV *command = newSV(0);
- I32 num_matches;
+ IV num_matches;
sv_setpvf(command, "my $string = '%s'; @array = ($string =~ %s)",
SvPV_nolen(string), pattern);
diff --git a/pod/perlguts.pod b/pod/perlguts.pod
index 8f3ed0c..56c48f0 100644
--- a/pod/perlguts.pod
+++ b/pod/perlguts.pod
@@ -332,7 +332,7 @@ empty AV:
The second method both creates the AV and initially populates it with SVs:
- AV* av_make(I32 num, SV **ptr);
+ AV* av_make(IV num, SV **ptr);
The second argument points to an array containing C<num> C<SV*>'s. Once the
AV has been created, the SVs can be destroyed, if so desired.
@@ -342,7 +342,7 @@ Once the AV has been created, the following operations are possible on it:
void av_push(AV*, SV*);
SV* av_pop(AV*);
SV* av_shift(AV*);
- void av_unshift(AV*, I32 num);
+ void av_unshift(AV*, IV num);
These should be familiar operations, with the exception of C<av_unshift>.
This routine adds C<num> elements at the front of the array with the C<undef>
@@ -351,9 +351,9 @@ to these new elements.
Here are some other functions:
- I32 av_len(AV*);
- SV** av_fetch(AV*, I32 key, I32 lval);
- SV** av_store(AV*, I32 key, SV* val);
+ IV av_len(AV*);
+ SV** av_fetch(AV*, IV key, I32 lval);
+ SV** av_store(AV*, IV key, SV* val);
The C<av_len> function returns the highest index value in an array (just
like $#array in Perl). If the array is empty, -1 is returned. The
@@ -370,7 +370,7 @@ A few more:
void av_clear(AV*);
void av_undef(AV*);
- void av_extend(AV*, I32 key);
+ void av_extend(AV*, IV key);
The C<av_clear> function deletes all the elements in the AV* array, but
does not actually delete the array itself. The C<av_undef> function will
diff --git a/pp.c b/pp.c
index 661c055..4271215 100644
--- a/pp.c
+++ b/pp.c
@@ -83,11 +83,11 @@ PP(pp_padav)
}
gimme = GIMME_V;
if (gimme == G_ARRAY) {
- const I32 maxarg = AvFILL(MUTABLE_AV(TARG)) + 1;
+ const Size_t maxarg = AvFILL(MUTABLE_AV(TARG)) + 1;
EXTEND(SP, maxarg);
if (SvMAGICAL(TARG)) {
- U32 i;
- for (i=0; i < (U32)maxarg; i++) {
+ Size_t i;
+ for (i=0; i < maxarg; i++) {
SV * const * const svp = av_fetch(MUTABLE_AV(TARG), i, FALSE);
SP[i+1] = (svp) ? *svp : &PL_sv_undef;
}
@@ -99,7 +99,7 @@ PP(pp_padav)
}
else if (gimme == G_SCALAR) {
SV* const sv = sv_newmortal();
- const I32 maxarg = AvFILL(MUTABLE_AV(TARG)) + 1;
+ const IV maxarg = AvFILL(MUTABLE_AV(TARG)) + 1;
sv_setiv(sv, maxarg);
PUSHs(sv);
}
@@ -4250,9 +4250,9 @@ PP(pp_aslice)
if (lval && localizing) {
register SV **svp;
- I32 max = -1;
+ IV max = -1;
for (svp = MARK + 1; svp <= SP; svp++) {
- const I32 elem = SvIV(*svp);
+ const IV elem = SvIV(*svp);
if (elem > max)
max = elem;
}
@@ -4262,7 +4262,7 @@ PP(pp_aslice)
while (++MARK <= SP) {
register SV **svp;
- I32 elem = SvIV(*MARK);
+ IV elem = SvIV(*MARK);
bool preeminent = TRUE;
if (localizing && can_preserve) {
@@ -4484,7 +4484,7 @@ S_do_delete_local(pTHX)
if (PL_op->op_flags & OPf_SPECIAL) {
AV * const av = MUTABLE_AV(osv);
while (++MARK <= end) {
- I32 idx = SvIV(*MARK);
+ IV idx = SvIV(*MARK);
SV *sv = NULL;
bool preeminent = TRUE;
if (can_preserve)
@@ -4827,12 +4827,12 @@ PP(pp_splice)
register AV *ary = DEREF_PLAIN_ARRAY(MUTABLE_AV(*++MARK));
register SV **src;
register SV **dst;
- register I32 i;
- register I32 offset;
- register I32 length;
- I32 newlen;
- I32 after;
- I32 diff;
+ register IV i;
+ register IV offset;
+ register IV length;
+ IV newlen;
+ IV after;
+ IV diff;
const MAGIC * const mg = SvTIED_mg((const SV *)ary, PERL_MAGIC_tied);
if (mg) {
@@ -5089,7 +5089,7 @@ PP(pp_unshift)
SPAGAIN;
}
else {
- register I32 i = 0;
+ register IV i = 0;
av_unshift(ary, SP - MARK);
while (MARK < SP) {
SV * const sv = newSVsv(*++MARK);
@@ -5120,7 +5120,7 @@ PP(pp_reverse)
SP = MARK;
if (SvMAGICAL(av)) {
- I32 i, j;
+ IV i, j;
register SV *tmp = sv_newmortal();
/* For SvCANEXISTDELETE */
HV *stash;
@@ -5183,7 +5183,7 @@ PP(pp_reverse)
else {
register char *up;
register char *down;
- register I32 tmp;
+ register char tmp;
dTARGET;
STRLEN len;
@@ -5216,7 +5216,7 @@ PP(pp_reverse)
while (down > up) {
tmp = *up;
*up++ = *down;
- *down-- = (char)tmp;
+ *down-- = tmp;
}
}
}
@@ -5226,7 +5226,7 @@ PP(pp_reverse)
while (down > up) {
tmp = *up;
*up++ = *down;
- *down-- = (char)tmp;
+ *down-- = tmp;
}
(void)SvPOK_only_UTF8(TARG);
}
@@ -5250,9 +5250,9 @@ PP(pp_split)
register REGEXP *rx;
register SV *dstr;
register const char *m;
- I32 iters = 0;
const STRLEN slen = do_utf8 ? utf8_length((U8*)s, (U8*)strend) : (STRLEN)(strend - s);
- I32 maxiters = slen + 10;
+ IV maxiters = (IV)slen + 10;
+ IV iters = 0;
I32 trailing_empty = 0;
const char *orig;
const I32 origlimit = limit;
@@ -5648,7 +5648,7 @@ PP(pp_split)
LEAVE_with_name("call_PUSH");
SPAGAIN;
if (gimme == G_ARRAY) {
- I32 i;
+ IV i;
/* EXTEND should not be needed - we just popped them */
EXTEND(SP, iters);
for (i=0; i < iters; i++) {
diff --git a/pp.h b/pp.h
index 7f1b770..552446a 100644
--- a/pp.h
+++ b/pp.h
@@ -439,7 +439,7 @@ Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
} \
else if ((flags & AMGf_want_list) && gimme == G_ARRAY) { \
int i; \
- I32 len; \
+ IV len; \
assert(SvTYPE(tmpsv) == SVt_PVAV); \
len = av_len((AV *)tmpsv) + 1; \
(void)POPs; /* get rid of the arg */ \
diff --git a/pp_ctl.c b/pp_ctl.c
index 54f17ae..25847a9 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1879,7 +1879,7 @@ PP(pp_caller)
&& CopSTASH_eq(PL_curcop, PL_debstash))
{
AV * const ary = cx->blk_sub.argarray;
- const int off = AvARRAY(ary) - AvALLOC(ary);
+ const IV off = AvARRAY(ary) - AvALLOC(ary);
Perl_init_dbargs(aTHX);
@@ -3153,7 +3153,7 @@ S_save_lines(pTHX_ AV *array, SV *sv)
{
const char *s = SvPVX_const(sv);
const char * const send = SvPVX_const(sv) + SvCUR(sv);
- I32 line = 1;
+ line_t line = 1;
PERL_ARGS_ASSERT_SAVE_LINES;
@@ -3715,7 +3715,7 @@ PP(pp_require)
}
if (!tryrsfp && !(errno == EACCES && path_is_absolute(name))) {
AV * const ar = GvAVn(PL_incgv);
- I32 i;
+ IV i;
#ifdef VMS
if (vms_unixname)
#endif
@@ -3928,7 +3928,7 @@ PP(pp_require)
} else {
if (namesv) { /* did we lookup @INC? */
AV * const ar = GvAVn(PL_incgv);
- I32 i;
+ IV i;
SV *const inc = newSVpvs_flags("", SVs_TEMP);
for (i = 0; i <= AvFILL(ar); i++) {
sv_catpvs(inc, " ");
@@ -4469,10 +4469,10 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
}
else if (SvROK(d) && SvTYPE(SvRV(d)) == SVt_PVAV) {
/* Test sub truth for each element */
- I32 i;
+ IV i;
bool andedresults = TRUE;
AV *av = (AV*) SvRV(d);
- const I32 len = av_len(av);
+ const IV len = av_len(av);
DEBUG_M(Perl_deb(aTHX_ " applying rule Array-CodeRef\n"));
if (len == -1)
RETPUSHYES;
@@ -4584,8 +4584,8 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
}
else if (SvROK(d) && SvTYPE(SvRV(d)) == SVt_PVAV) {
AV * const other_av = MUTABLE_AV(SvRV(d));
- const I32 other_len = av_len(other_av) + 1;
- I32 i;
+ const IV other_len = av_len(other_av) + 1;
+ IV i;
HV *hv = MUTABLE_HV(SvRV(e));
DEBUG_M(Perl_deb(aTHX_ " applying rule Array-Hash\n"));
@@ -4636,8 +4636,8 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
}
else if (SvROK(d) && SvTYPE(SvRV(d)) == SVt_PVHV) {
AV * const other_av = MUTABLE_AV(SvRV(e));
- const I32 other_len = av_len(other_av) + 1;
- I32 i;
+ const IV other_len = av_len(other_av) + 1;
+ IV i;
DEBUG_M(Perl_deb(aTHX_ " applying rule Hash-Array\n"));
for (i = 0; i < other_len; ++i) {
@@ -4657,8 +4657,8 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
if (av_len(MUTABLE_AV(SvRV(e))) != av_len(other_av))
RETPUSHNO;
else {
- I32 i;
- const I32 other_len = av_len(other_av);
+ IV i;
+ const IV other_len = av_len(other_av);
if (NULL == seen_this) {
seen_this = newHV();
@@ -4713,8 +4713,8 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
sm_regex_array:
{
PMOP * const matcher = make_matcher((REGEXP*) SvRV(d));
- const I32 this_len = av_len(MUTABLE_AV(SvRV(e)));
- I32 i;
+ const IV this_len = av_len(MUTABLE_AV(SvRV(e)));
+ IV i;
for(i = 0; i <= this_len; ++i) {
SV * const * const svp = av_fetch(MUTABLE_AV(SvRV(e)), i, FALSE);
@@ -4730,8 +4730,8 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
}
else if (!SvOK(d)) {
/* undef ~~ array */
- const I32 this_len = av_len(MUTABLE_AV(SvRV(e)));
- I32 i;
+ const IV this_len = av_len(MUTABLE_AV(SvRV(e)));
+ IV i;
DEBUG_M(Perl_deb(aTHX_ " applying rule Undef-Array\n"));
for (i = 0; i <= this_len; ++i) {
@@ -4745,8 +4745,8 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
else {
sm_any_array:
{
- I32 i;
- const I32 this_len = av_len(MUTABLE_AV(SvRV(e)));
+ IV i;
+ const IV this_len = av_len(MUTABLE_AV(SvRV(e)));
DEBUG_M(Perl_deb(aTHX_ " applying rule Any-Array\n"));
for (i = 0; i <= this_len; ++i) {
diff --git a/pp_hot.c b/pp_hot.c
index 38c49a0..c73ed11 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -844,12 +844,12 @@ PP(pp_rv2av)
(until such time as we get tools that can do blame annotation across
whitespace changes. */
if (gimme == G_ARRAY) {
- const I32 maxarg = AvFILL(av) + 1;
+ const IV maxarg = AvFILL(av) + 1;
(void)POPs; /* XXXX May be optimized away? */
EXTEND(SP, maxarg);
if (SvRMAGICAL(av)) {
- U32 i;
- for (i=0; i < (U32)maxarg; i++) {
+ UV i;
+ for (i=0; i < (UV)maxarg; i++) {
SV ** const svp = av_fetch(av, i, FALSE);
/* See note in pp_helem, and bug id #27839 */
SP[i+1] = svp
@@ -864,7 +864,7 @@ PP(pp_rv2av)
}
else if (gimme == G_SCALAR) {
dTARGET;
- const I32 maxarg = AvFILL(av) + 1;
+ const IV maxarg = AvFILL(av) + 1;
SETi(maxarg);
}
} else {
@@ -941,7 +941,6 @@ PP(pp_aassign)
I32 gimme;
HV *hash;
- I32 i;
int magic;
int duplicates = 0;
SV **firsthashrelem = NULL; /* "= 0" keeps gcc 2.95 quiet */
@@ -993,7 +992,8 @@ PP(pp_aassign)
TAINT_NOT; /* Each item stands on its own, taintwise. */
sv = *lelem++;
switch (SvTYPE(sv)) {
- case SVt_PVAV:
+ case SVt_PVAV: {
+ IV i;
ary = MUTABLE_AV(sv);
magic = SvMAGICAL(ary) != 0;
ENTER;
@@ -1020,6 +1020,7 @@ PP(pp_aassign)
SvSETMAGIC(MUTABLE_SV(ary));
LEAVE;
break;
+ }
case SVt_PVHV: { /* normal hash */
SV *tmpstr;
SV** topelem = relem;
diff --git a/pp_sort.c b/pp_sort.c
index 813cd2c..1cb5f45 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1474,7 +1474,7 @@ PP(pp_sort)
{
dVAR; dSP; dMARK; dORIGMARK;
register SV **p1 = ORIGMARK+1, **p2;
- register I32 max, i;
+ register IV max, i;
AV* av = NULL;
HV *stash;
GV *gv;
diff --git a/proto.h b/proto.h
index 946e9fe..c12071b 100644
--- a/proto.h
+++ b/proto.h
@@ -122,29 +122,29 @@ PERL_CALLCONV SV** Perl_av_create_and_unshift_one(pTHX_ AV **const avp, SV *cons
#define PERL_ARGS_ASSERT_AV_CREATE_AND_UNSHIFT_ONE \
assert(avp); assert(val)
-PERL_CALLCONV SV* Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags)
+PERL_CALLCONV SV* Perl_av_delete(pTHX_ AV *av, IV key, I32 flags)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_AV_DELETE \
assert(av)
-PERL_CALLCONV bool Perl_av_exists(pTHX_ AV *av, I32 key)
+PERL_CALLCONV bool Perl_av_exists(pTHX_ AV *av, IV key)
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_AV_EXISTS \
assert(av)
-PERL_CALLCONV void Perl_av_extend(pTHX_ AV *av, I32 key)
+PERL_CALLCONV void Perl_av_extend(pTHX_ AV *av, IV key)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_AV_EXTEND \
assert(av)
-PERL_CALLCONV SV** Perl_av_fetch(pTHX_ AV *av, I32 key, I32 lval)
+PERL_CALLCONV SV** Perl_av_fetch(pTHX_ AV *av, IV key, I32 lval)
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_AV_FETCH \
assert(av)
-PERL_CALLCONV void Perl_av_fill(pTHX_ AV *av, I32 fill)
+PERL_CALLCONV void Perl_av_fill(pTHX_ AV *av, IV fill)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_AV_FILL \
assert(av)
@@ -154,13 +154,13 @@ PERL_CALLCONV IV* Perl_av_iter_p(pTHX_ AV *av)
#define PERL_ARGS_ASSERT_AV_ITER_P \
assert(av)
-PERL_CALLCONV I32 Perl_av_len(pTHX_ AV *av)
+PERL_CALLCONV IV Perl_av_len(pTHX_ AV *av)
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_AV_LEN \
assert(av)
-PERL_CALLCONV AV* Perl_av_make(pTHX_ I32 size, SV **strp)
+PERL_CALLCONV AV* Perl_av_make(pTHX_ IV size, SV **strp)
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_2);
#define PERL_ARGS_ASSERT_AV_MAKE \
@@ -188,7 +188,7 @@ PERL_CALLCONV SV* Perl_av_shift(pTHX_ AV *av)
#define PERL_ARGS_ASSERT_AV_SHIFT \
assert(av)
-PERL_CALLCONV SV** Perl_av_store(pTHX_ AV *av, I32 key, SV *val)
+PERL_CALLCONV SV** Perl_av_store(pTHX_ AV *av, IV key, SV *val)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_AV_STORE \
assert(av)
@@ -198,7 +198,7 @@ PERL_CALLCONV void Perl_av_undef(pTHX_ AV *av)
#define PERL_ARGS_ASSERT_AV_UNDEF \
assert(av)
-PERL_CALLCONV void Perl_av_unshift(pTHX_ AV *av, I32 num)
+PERL_CALLCONV void Perl_av_unshift(pTHX_ AV *av, IV num)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_AV_UNSHIFT \
assert(av)
@@ -3419,16 +3419,16 @@ PERL_CALLCONV void Perl_save_I8(pTHX_ I8* bytep)
#define PERL_ARGS_ASSERT_SAVE_I8 \
assert(bytep)
-PERL_CALLCONV void Perl_save_adelete(pTHX_ AV *av, I32 key)
+PERL_CALLCONV void Perl_save_adelete(pTHX_ AV *av, IV key)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_SAVE_ADELETE \
assert(av)
-/* PERL_CALLCONV void Perl_save_aelem(pTHX_ AV* av, I32 idx, SV **sptr)
+/* PERL_CALLCONV void Perl_save_aelem(pTHX_ AV* av, IV idx, SV **sptr)
__attribute__nonnull__(pTHX_1)
__attribute__nonnull__(pTHX_3); */
-PERL_CALLCONV void Perl_save_aelem_flags(pTHX_ AV* av, I32 idx, SV **sptr, const U32 flags)
+PERL_CALLCONV void Perl_save_aelem_flags(pTHX_ AV* av, IV idx, SV **sptr, const U32 flags)
__attribute__nonnull__(pTHX_1)
__attribute__nonnull__(pTHX_3);
#define PERL_ARGS_ASSERT_SAVE_AELEM_FLAGS \
@@ -3557,6 +3557,7 @@ PERL_CALLCONV void Perl_save_pptr(pTHX_ char** pptr)
assert(pptr)
PERL_CALLCONV void Perl_save_pushi32ptr(pTHX_ const I32 i, void *const ptr, const int type);
+PERL_CALLCONV void Perl_save_pushivptr(pTHX_ const IV i, void *const ptr, const int type);
PERL_CALLCONV void Perl_save_pushptr(pTHX_ void *const ptr, const int type);
PERL_CALLCONV void Perl_save_pushptrptr(pTHX_ void *const ptr1, void *const ptr2, const int type);
PERL_CALLCONV void Perl_save_re_context(pTHX);
@@ -6822,6 +6823,7 @@ STATIC U8* S_reghop4(U8 *s, I32 off, const U8 *llim, const U8 *rlim)
#endif
#if defined(PERL_IN_SCOPE_C)
STATIC void S_save_pushptri32ptr(pTHX_ void *const ptr1, const I32 i, void *const ptr2, const int type);
+STATIC void S_save_pushptrivptr(pTHX_ void *const ptr1, const IV i, void *const ptr2, const int type);
STATIC SV* S_save_scalar_at(pTHX_ SV **sptr, const U32 flags)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_SAVE_SCALAR_AT \
diff --git a/regexec.c b/regexec.c
index b67a1c3..bb6776a 100644
--- a/regexec.c
+++ b/regexec.c
@@ -6990,7 +6990,7 @@ S_reginclass(pTHX_ const regexp * const prog, register const regnode * const n,
/* Do the linear search to see if the fold is in the list
* of multi-char folds. */
if (av) {
- I32 i;
+ IV i;
for (i = 0; i <= av_len(av); i++) {
SV* const sv = *av_fetch(av, i, FALSE);
STRLEN len;
diff --git a/scope.c b/scope.c
index 2a9b3d5..104101a 100644
--- a/scope.c
+++ b/scope.c
@@ -381,6 +381,16 @@ Perl_save_pushi32ptr(pTHX_ const I32 i, void *const ptr, const int type)
}
void
+Perl_save_pushivptr(pTHX_ const IV i, void *const ptr, const int type)
+{
+ dVAR;
+ SSCHECK(3);
+ SSPUSHIV(i);
+ SSPUSHPTR(ptr);
+ SSPUSHUV(type);
+}
+
+void
Perl_save_int(pTHX_ int *intp)
{
dVAR;
@@ -555,14 +565,14 @@ Perl_save_hdelete(pTHX_ HV *hv, SV *keysv)
}
void
-Perl_save_adelete(pTHX_ AV *av, I32 key)
+Perl_save_adelete(pTHX_ AV *av, IV key)
{
dVAR;
PERL_ARGS_ASSERT_SAVE_ADELETE;
SvREFCNT_inc_void(av);
- save_pushi32ptr(key, av, SAVEt_ADELETE);
+ save_pushivptr(key, av, SAVEt_ADELETE);
}
void
@@ -614,8 +624,19 @@ S_save_pushptri32ptr(pTHX_ void *const ptr1, const I32 i, void *const ptr2,
SSPUSHUV(type);
}
+static void
+S_save_pushptrivptr(pTHX_ void *const ptr1, const IV i, void *const ptr2,
+ const int type)
+{
+ SSCHECK(4);
+ SSPUSHPTR(ptr1);
+ SSPUSHIV(i);
+ SSPUSHPTR(ptr2);
+ SSPUSHUV(type);
+}
+
void
-Perl_save_aelem_flags(pTHX_ AV *av, I32 idx, SV **sptr, const U32 flags)
+Perl_save_aelem_flags(pTHX_ AV *av, IV idx, SV **sptr, const U32 flags)
{
dVAR;
SV *sv;
@@ -623,7 +644,7 @@ Perl_save_aelem_flags(pTHX_ AV *av, I32 idx, SV **sptr, const U32 flags)
PERL_ARGS_ASSERT_SAVE_AELEM_FLAGS;
SvGETMAGIC(*sptr);
- save_pushptri32ptr(SvREFCNT_inc_simple(av), idx, SvREFCNT_inc(*sptr),
+ save_pushptrivptr(SvREFCNT_inc_simple(av), idx, SvREFCNT_inc(*sptr),
SAVEt_AELEM);
/* if it gets reified later, the restore will have the wrong refcnt */
if (!AvREAL(av) && AvREIFY(av))
@@ -710,6 +731,7 @@ Perl_leave_scope(pTHX_ I32 base)
void* ptr;
register char* str;
I32 i;
+ IV iv;
/* Localise the effects of the TAINT_NOT inside the loop. */
bool was = PL_tainted;
@@ -961,8 +983,8 @@ Perl_leave_scope(pTHX_ I32 base)
case SAVEt_ADELETE:
ptr = SSPOPPTR;
av = MUTABLE_AV(ptr);
- i = SSPOPINT;
- (void)av_delete(av, i, G_DISCARD);
+ iv = SSPOPIV;
+ (void)av_delete(av, iv, G_DISCARD);
SvREFCNT_dec(av);
break;
case SAVEt_DESTRUCTOR_X:
@@ -984,9 +1006,9 @@ Perl_leave_scope(pTHX_ I32 base)
break;
case SAVEt_AELEM: /* array element */
value = MUTABLE_SV(SSPOPPTR);
- i = SSPOPINT;
+ iv = SSPOPIV;
av = MUTABLE_AV(SSPOPPTR);
- ptr = av_fetch(av,i,1);
+ ptr = av_fetch(av,iv,1);
if (!AvREAL(av) && AvREIFY(av)) /* undo reify guard */
SvREFCNT_dec(value);
if (ptr) {
diff --git a/scope.h b/scope.h
index f8df5b4..51e4394 100644
--- a/scope.h
+++ b/scope.h
@@ -190,7 +190,7 @@ scope has the given name. Name must be a literal string.
#define SAVEHDELETE(h,s) \
save_hdelete(MUTABLE_HV(h), (s))
#define SAVEADELETE(a,k) \
- save_adelete(MUTABLE_AV(a), (I32)(k))
+ save_adelete(MUTABLE_AV(a), (k))
#define SAVEDESTRUCTOR(f,p) \
save_destructor((DESTRUCTORFUNC_NOCONTEXT_t)(f), (void*)(p))
diff --git a/sv.c b/sv.c
index dd78927..3dcaba3 100644
--- a/sv.c
+++ b/sv.c
@@ -14100,7 +14100,7 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv,
AV *av = MUTABLE_AV(PAD_SV(obase->op_targ));
if (!av || SvRMAGICAL(av))
break;
- svp = av_fetch(av, (I32)obase->op_private, FALSE);
+ svp = av_fetch(av, obase->op_private, FALSE);
if (!svp || *svp != uninit_sv)
break;
}
@@ -14116,7 +14116,7 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv,
AV *const av = GvAV(gv);
if (!av || SvRMAGICAL(av))
break;
- svp = av_fetch(av, (I32)obase->op_private, FALSE);
+ svp = av_fetch(av, obase->op_private, FALSE);
if (!svp || *svp != uninit_sv)
break;
}
diff --git a/toke.c b/toke.c
index f4394b5..80a47a0 100644
--- a/toke.c
+++ b/toke.c
@@ -1766,7 +1766,7 @@ S_update_debugger_info(pTHX_ SV *orig_sv, const char *const buf, STRLEN len)
sv_setpvn(sv, buf, len);
(void)SvIOK_on(sv);
SvIV_set(sv, 0);
- av_store(av, (I32)CopLINE(PL_curcop), sv);
+ av_store(av, CopLINE(PL_curcop), sv);
}
}
diff --git a/universal.c b/universal.c
index a7c480f..4f066a2 100644
--- a/universal.c
+++ b/universal.c
@@ -1022,9 +1022,9 @@ XS(XS_PerlIO_get_layers)
if (gv && (io = GvIO(gv))) {
AV* const av = PerlIO_get_layers(aTHX_ input ?
IoIFP(io) : IoOFP(io));
- I32 i;
- const I32 last = av_len(av);
- I32 nitem = 0;
+ IV i;
+ const IV last = av_len(av);
+ IV nitem = 0;
for (i = last; i >= 0; i -= 3) {
SV * const * const namsvp = av_fetch(av, i - 2, FALSE);
@@ -1203,8 +1203,8 @@ XS(XS_re_regnames)
U32 flags;
SV *ret;
AV *av;
- I32 length;
- I32 i;
+ IV length;
+ IV i;
SV **entry;
if (items > 1)
diff --git a/utf8.c b/utf8.c
index 2592728..1310a9b 100644
--- a/utf8.c
+++ b/utf8.c
@@ -3797,12 +3797,12 @@ Perl__swash_inversion_hash(pTHX_ SV* const swash)
&char_to, &to_len)))
{
if (av_len(from_list) > 0) {
- int i;
+ IV i;
/* We iterate over all combinations of i,j to place each code
* point on each list */
for (i = 0; i <= av_len(from_list); i++) {
- int j;
+ IV j;
AV* i_list = newAV();
SV** entryp = av_fetch(from_list, i, FALSE);
if (entryp == NULL) {
diff --git a/util.c b/util.c
index 94f92b2..dbfa0dc 100644
--- a/util.c
+++ b/util.c
@@ -4634,7 +4634,7 @@ Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv)
}
}
if ( qv ) { /* quoted versions always get at least three terms*/
- I32 len = av_len(av);
+ IV len = av_len(av);
/* This for loop appears to trigger a compiler bug on OS X, as it
loops infinitely. Yes, len is negative. No, it makes no sense.
Compiler in question is:
@@ -4699,7 +4699,7 @@ Perl_new_version(pTHX_ SV *ver)
if ( sv_isobject(ver) && sv_derived_from(ver, "version") )
/* can just copy directly */
{
- I32 key;
+ IV key;
AV * const av = newAV();
AV *sav;
/* This will get reblessed later if a derived class*/
@@ -4938,7 +4938,7 @@ The SV returned has a refcount of 1.
SV *
Perl_vnumify(pTHX_ SV *vs)
{
- I32 i, len, digit;
+ IV i, len, digit;
int width;
bool alpha = FALSE;
SV *sv;
@@ -5019,7 +5019,7 @@ The SV returned has a refcount of 1.
SV *
Perl_vnormal(pTHX_ SV *vs)
{
- I32 i, len, digit;
+ IV i, len, digit;
bool alpha = FALSE;
SV *sv;
AV *av;
@@ -5115,11 +5115,12 @@ converted into version objects.
int
Perl_vcmp(pTHX_ SV *lhv, SV *rhv)
{
- I32 i,l,m,r,retval;
+ IV i,l,m,r;
+ int retval;
bool lalpha = FALSE;
bool ralpha = FALSE;
- I32 left = 0;
- I32 right = 0;
+ IV left = 0;
+ IV right = 0;
AV *lav, *rav;
PERL_ARGS_ASSERT_VCMP;
diff --git a/vms/vms.c b/vms/vms.c
index a8e42c4..9e5ce2a 100644
--- a/vms/vms.c
+++ b/vms/vms.c
@@ -12943,7 +12943,7 @@ mod2fname(pTHX_ CV *cv)
dXSARGS;
char ultimate_name[NAM$C_MAXRSS+1], work_name[NAM$C_MAXRSS*8 + 1],
workbuff[NAM$C_MAXRSS*1 + 1];
- int counter, num_entries;
+ IV counter, num_entries;
/* ODS-5 ups this, but we want to be consistent, so... */
int max_name_len = 39;
AV *in_array = (AV *)SvRV(ST(0));
--
Chip Salzenberg
Thread Next
-
[PATCH] make array interface 64-bit safe by using IV instead of I32
by Rev. Chip