mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 16:39:36 +00:00
pp_i_modulo(): remove workaround for ancient glibc bug
Old glibc versions had a buggy modulo implementation for 64 bit integers on 32-bit architectures. This was fixed in glibc 2.3, released in 2002 (the version check in the code is overly cautious). Removing the alternate PP function support is left for the next commit, in case we need to resurrect it in future.
This commit is contained in:
parent
d20228ab36
commit
f955cd4a58
22
perl.c
22
perl.c
@ -216,26 +216,6 @@ Initializes a new Perl interpreter. See L<perlembed>.
|
||||
=cut
|
||||
*/
|
||||
|
||||
static void
|
||||
S_fixup_platform_bugs(void)
|
||||
{
|
||||
#if defined(__GLIBC__) && IVSIZE == 8 \
|
||||
&& ( __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 8))
|
||||
{
|
||||
IV l = 3;
|
||||
IV r = -10;
|
||||
/* Cannot do this check with inlined IV constants since
|
||||
* that seems to work correctly even with the buggy glibc. */
|
||||
if (l % r == -3) {
|
||||
dTHX;
|
||||
/* Yikes, we have the bug.
|
||||
* Patch in the workaround version. */
|
||||
PL_ppaddr[OP_I_MODULO] = &Perl_pp_i_modulo_glibc_bugfix;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
perl_construct(pTHXx)
|
||||
{
|
||||
@ -296,8 +276,6 @@ perl_construct(pTHXx)
|
||||
|
||||
init_ids();
|
||||
|
||||
S_fixup_platform_bugs();
|
||||
|
||||
JMPENV_BOOTSTRAP;
|
||||
STATUS_ALL_SUCCESS;
|
||||
|
||||
|
||||
25
pp.c
25
pp.c
@ -2654,7 +2654,6 @@ PP(pp_i_divide)
|
||||
|
||||
PP(pp_i_modulo)
|
||||
{
|
||||
/* This is the vanilla old i_modulo. */
|
||||
dSP; dATARGET;
|
||||
tryAMAGICbin_MG(modulo_amg, AMGf_assign);
|
||||
{
|
||||
@ -2670,30 +2669,6 @@ PP(pp_i_modulo)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__GLIBC__) && IVSIZE == 8 \
|
||||
&& ( __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 8))
|
||||
|
||||
PP(pp_i_modulo_glibc_bugfix)
|
||||
{
|
||||
/* This is the i_modulo with the workaround for the _moddi3 bug
|
||||
* in (at least) glibc 2.2.5 (the PERL_ABS() the workaround).
|
||||
* See below for pp_i_modulo. */
|
||||
dSP; dATARGET;
|
||||
tryAMAGICbin_MG(modulo_amg, AMGf_assign);
|
||||
{
|
||||
dPOPTOPiirl_nomg;
|
||||
if (!right)
|
||||
DIE(aTHX_ "Illegal modulus zero");
|
||||
/* avoid FPE_INTOVF on some platforms when left is IV_MIN */
|
||||
if (right == -1)
|
||||
SETi( 0 );
|
||||
else
|
||||
SETi( left % PERL_ABS(right) );
|
||||
RETURN;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
PP(pp_i_add)
|
||||
{
|
||||
dSP; dATARGET;
|
||||
|
||||
@ -298,9 +298,4 @@ PERL_CALLCONV OP *Perl_pp_warn(pTHX);
|
||||
PERL_CALLCONV OP *Perl_pp_xor(pTHX);
|
||||
PERL_CALLCONV OP *Perl_unimplemented_op(pTHX);
|
||||
|
||||
/* alternative functions */
|
||||
#if defined(__GLIBC__) && IVSIZE == 8 && ( __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 8))
|
||||
PERL_CALLCONV OP *Perl_pp_i_modulo_glibc_bugfix(pTHX);
|
||||
#endif
|
||||
|
||||
/* ex: set ro: */
|
||||
|
||||
@ -139,13 +139,6 @@ my @raw_alias = (
|
||||
Perl_pp_shostent => [qw(snetent sprotoent sservent)],
|
||||
Perl_pp_aelemfast => ['aelemfast_lex'],
|
||||
Perl_pp_grepstart => ['mapstart'],
|
||||
|
||||
# 2 i_modulo mappings: 2nd is alt, needs 1st (explicit default) to not override the default
|
||||
Perl_pp_i_modulo => ['i_modulo'],
|
||||
Perl_pp_i_modulo_glibc_bugfix => {
|
||||
'i_modulo' =>
|
||||
'#if defined(__GLIBC__) && IVSIZE == 8 '.
|
||||
' && ( __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 8))' },
|
||||
);
|
||||
|
||||
while (my ($func, $names) = splice @raw_alias, 0, 2) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user