X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pp.c;h=53aea9b8350e1d1dacf4ce0d5a4df055eeb26b72;hb=5cfbcfcdc45b1cdd758241f7f02495ded7acc722;hp=bb3ac68dda3768169acd310897c62c2c911ee490;hpb=32fdb0651975fc8e2d4b926fd3bd5792b31acf57;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pp.c b/pp.c index bb3ac68..53aea9b 100644 --- a/pp.c +++ b/pp.c @@ -1,6 +1,7 @@ /* pp.c * - * Copyright (c) 1991-2003, Larry Wall + * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + * 2000, 2001, 2002, 2003, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -857,6 +858,7 @@ PP(pp_postinc) else sv_inc(TOPs); SvSETMAGIC(TOPs); + /* special case for undef: see thread at 2003-03/msg00536.html in archive */ if (!SvOK(TARG)) sv_setiv(TARG, 0); SETs(TARG); @@ -2471,12 +2473,12 @@ PP(pp_i_modulo_0) } } +#if defined(__GLIBC__) && IVSIZE == 8 STATIC PP(pp_i_modulo_1) { -#ifdef __GLIBC__ /* This is the i_modulo with the workaround for the _moddi3 bug - * in (at least) glibc 2.2.5 (the "right = -right" is the workaround). + * in (at least) glibc 2.2.5 (the PERL_ABS() the workaround). * See below for pp_i_modulo. */ dSP; dATARGET; tryAMAGICbin(modulo,opASSIGN); { @@ -2486,8 +2488,8 @@ PP(pp_i_modulo_1) SETi( left % PERL_ABS(right) ); RETURN; } -#endif } +#endif PP(pp_i_modulo) { @@ -2889,24 +2891,14 @@ PP(pp_int) SETu(U_V(value)); } else { #if defined(SPARC64_MODF_WORKAROUND) - (void)sparc64_workaround_modf(value, &value); -#else -# if defined(HAS_MODFL) || defined(LONG_DOUBLE_EQUALS_DOUBLE) -# ifdef HAS_MODFL_POW32_BUG + (void)sparc64_workaround_modf(value, &value); +#elif defined(HAS_MODFL_POW32_BUG) /* some versions of glibc split (i + d) into (i-1, d+1) for 2^32 <= i < 2^64 */ - { - NV offset = Perl_modf(value, &value); - (void)Perl_modf(offset, &offset); - value += offset; - } -# else - (void)Perl_modf(value, &value); -# endif -# else - double tmp = (double)value; - (void)Perl_modf(tmp, &tmp); - value = (NV)tmp; -# endif + NV offset = Perl_modf(value, &value); + (void)Perl_modf(offset, &offset); + value += offset; +#else + (void)Perl_modf(value, &value); #endif SETn(value); } @@ -2915,24 +2907,17 @@ PP(pp_int) if (value > (NV)IV_MIN - 0.5) { SETi(I_V(value)); } else { -#if defined(HAS_MODFL) || defined(LONG_DOUBLE_EQUALS_DOUBLE) -# ifdef HAS_MODFL_POW32_BUG +#if defined(SPARC64_MODF_WORKAROUND) + (void)sparc64_workaround_modf(-value, &value); +#elif defined(HAS_MODFL_POW32_BUG) /* some versions of glibc split (i + d) into (i-1, d+1) for 2^32 <= i < 2^64 */ - { - NV offset = Perl_modf(-value, &value); - (void)Perl_modf(offset, &offset); - value += offset; - } -# else - (void)Perl_modf(-value, &value); -# endif - value = -value; + NV offset = Perl_modf(-value, &value); + (void)Perl_modf(offset, &offset); + value += offset; #else - double tmp = (double)value; - (void)Perl_modf(-tmp, &tmp); - value = -(NV)tmp; + (void)Perl_modf(-value, &value); #endif - SETn(value); + SETn(-value); } } } @@ -3386,7 +3371,8 @@ PP(pp_chr) tmps = SvPVX(TARG); if (SvCUR(TARG) == 0 || !is_utf8_string((U8*)tmps, SvCUR(TARG)) || memEQ(tmps, "\xef\xbf\xbd\0", 4)) { - SvGROW(TARG,3); + SvGROW(TARG, 3); + tmps = SvPVX(TARG); SvCUR_set(TARG, 2); *tmps++ = (U8)UTF8_EIGHT_BIT_HI(value); *tmps++ = (U8)UTF8_EIGHT_BIT_LO(value); @@ -3417,6 +3403,24 @@ PP(pp_crypt) sv_utf8_downgrade(tsv, FALSE); tmps = SvPVX(tsv); } +# ifdef USE_ITHREADS +# ifdef HAS_CRYPT_R + if (!PL_reentrant_buffer->_crypt_struct_buffer) { + /* This should be threadsafe because in ithreads there is only + * one thread per interpreter. If this would not be true, + * we would need a mutex to protect this malloc. */ + PL_reentrant_buffer->_crypt_struct_buffer = + (struct crypt_data *)safemalloc(sizeof(struct crypt_data)); +#if defined(__GLIBC__) || defined(__EMX__) + if (PL_reentrant_buffer->_crypt_struct_buffer) { + PL_reentrant_buffer->_crypt_struct_buffer->initialized = 0; + /* work around glibc-2.2.5 bug */ + PL_reentrant_buffer->_crypt_struct_buffer->current_saltbits = 0; + } +#endif + } +# endif /* HAS_CRYPT_R */ +# endif /* USE_ITHREADS */ # ifdef FCRYPT sv_setpv(TARG, fcrypt(tmps, SvPV(right, n_a))); # else @@ -4759,12 +4763,10 @@ PP(pp_split) if (gimme == G_ARRAY) RETURN; } - if (iters || !pm->op_pmreplroot) { - GETTARGET; - PUSHi(iters); - RETURN; - } - RETPUSHUNDEF; + + GETTARGET; + PUSHi(iters); + RETURN; } PP(pp_lock)