Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.9k stars 540 forks source link

[PATCH] enable USE_64_BIT_INT for Visual C 6 #13536

Closed p5pRT closed 10 years ago

p5pRT commented 10 years ago

Migrated from rt.perl.org#121029 (status was 'rejected')

Searchable as RT121029$

p5pRT commented 10 years ago

From @bulk88

Created by @bulk88

See attached patch. This is a WIP. Comments requested. No comments on murdering VC6 please. Patching the CPAN stuff I'm not sure how arrange the logistics of\, since it requires a new macro\, but also backcompat with older perls.

Perl Info ``` Flags: category=core severity=low Site configuration information for perl 5.19.7: Configured by Owner at Thu Nov 28 02:32:44 2013. Summary of my perl5 (revision 5 version 19 subversion 7) configuration: Derived from: 8f47723e28b75530b743941cdd8b07f849ec48e2 Ancestor: 1061065f7a09399eefb50e9a035502621722bcc0 Platform: osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -G7 -GL -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPERL_HASH_FUNC_ONE_AT_A_TIME -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T', optimize='-O1 -MD -Zi -DNDEBUG -G7 -GL', cppflags='-DWIN32' ccversion='13.10.6030', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -ltcg -libpath:"c:\perl519\lib\CORE" -machine:x86' libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\lib" libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl519.lib gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -ltcg -libpath:"c:\perl519\lib\CORE" -machine:x86' Locally applied patches: uncommitted-changes 8f47723e28b75530b743941cdd8b07f849ec48e2 @INC for perl 5.19.7: C:/perl519/site/lib C:/perl519/lib . Environment for perl 5.19.7: HOME (unset) LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=C:\perl519\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE;C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\BIN;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\bin\prerelease;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem; PERL_BADLANG (unset) SHELL (unset) ```
p5pRT commented 10 years ago

From @bulk88

0001-WIP-enable-USE_64_BIT_INT-for-Visual-C-6.patch ```diff From 12ae418b641315096a793e7bc717478513e0d757 Mon Sep 17 00:00:00 2001 From: Daniel Dragan Date: Sat, 18 Jan 2014 00:35:57 -0500 Subject: [PATCH] WIP enable USE_64_BIT_INT for Visual C 6 --- README.win32 | 3 --- cpan/Encode/Encode.xs | 2 +- cpan/Scalar-List-Utils/ListUtil.xs | 2 +- cpan/Time-HiRes/HiRes.xs | 8 ++++---- dist/Math-BigInt-FastCalc/FastCalc.xs | 3 ++- handy.h | 6 ++---- hv_func.h | 10 +++++----- numeric.c | 18 +++++++++--------- perl.h | 33 ++++++++++++++++++++------------- pod/perldelta.pod | 6 ++++++ pp.c | 12 ++++++------ pp_hot.c | 2 +- pp_pack.c | 10 +++++----- sv.c | 12 ++++++------ toke.c | 6 +++--- win32/Makefile | 8 -------- win32/makefile.mk | 7 ------- 17 files changed, 71 insertions(+), 77 deletions(-) diff --git a/README.win32 b/README.win32 index e19b48c..a3b1b9a 100644 --- a/README.win32 +++ b/README.win32 @@ -373,9 +373,6 @@ the linker reports an internal error. If you want build some core extensions statically into perl's dll, specify them in the STATIC_EXT macro. -NOTE: The USE_64_BIT_INT build option is not supported with the 32-bit -Visual C++ 6.0 compiler. - Be sure to read the instructions near the top of the makefiles carefully. =item * diff --git a/cpan/Encode/Encode.xs b/cpan/Encode/Encode.xs index ea9265f..854e2cd 100644 --- a/cpan/Encode/Encode.xs +++ b/cpan/Encode/Encode.xs @@ -77,7 +77,7 @@ do_fallback_cb(pTHX_ UV ch, SV *fallback_cb) ENTER; SAVETMPS; PUSHMARK(sp); - XPUSHs(sv_2mortal(newSVnv((UV)ch))); + XPUSHs(sv_2mortal(newSVnv(UV2NV(ch)))) ; PUTBACK; argc = call_sv(fallback_cb, G_SCALAR); SPAGAIN; diff --git a/cpan/Scalar-List-Utils/ListUtil.xs b/cpan/Scalar-List-Utils/ListUtil.xs index af869ce..9e1d9f5 100644 --- a/cpan/Scalar-List-Utils/ListUtil.xs +++ b/cpan/Scalar-List-Utils/ListUtil.xs @@ -53,7 +53,7 @@ my_sv_copypv(pTHX_ SV *const dsv, SV *const ssv) #endif #ifdef SVf_IVisUV -# define slu_sv_value(sv) (SvIOK(sv)) ? (SvIOK_UV(sv)) ? (NV)(SvUVX(sv)) : (NV)(SvIVX(sv)) : (SvNV(sv)) +# define slu_sv_value(sv) (SvIOK(sv)) ? (SvIOK_UV(sv)) ? UV2NV(SvUVX(sv)) : (NV)(SvIVX(sv)) : (SvNV(sv)) #else # define slu_sv_value(sv) (SvIOK(sv)) ? (NV)(SvIVX(sv)) : (SvNV(sv)) #endif diff --git a/cpan/Time-HiRes/HiRes.xs b/cpan/Time-HiRes/HiRes.xs index 96640e9..f419bc7 100644 --- a/cpan/Time-HiRes/HiRes.xs +++ b/cpan/Time-HiRes/HiRes.xs @@ -874,7 +874,7 @@ sleep(...) if (items > 0) { NV seconds = SvNV(ST(0)); if (seconds >= 0.0) { - UV useconds = (UV)(1E6 * (seconds - (UV)seconds)); + UV useconds = (UV)(1E6 * (seconds - UV2NV((UV)seconds))); if (seconds >= 1.0) sleep((U32)seconds); if ((IV)useconds < 0) { @@ -1297,10 +1297,10 @@ PROTOTYPE: ;$ UV ctime_nsec; hrstatns(&atime_nsec, &mtime_nsec, &ctime_nsec); if (atime_nsec) - ST( 8) = sv_2mortal(newSVnv(atime + 1e-9 * (NV) atime_nsec)); + ST( 8) = sv_2mortal(newSVnv(UV2NV(atime) + 1e-9 * UV2NV(atime_nsec))); if (mtime_nsec) - ST( 9) = sv_2mortal(newSVnv(mtime + 1e-9 * (NV) mtime_nsec)); + ST( 9) = sv_2mortal(newSVnv(UV2NV(mtime) + 1e-9 * UV2NV(mtime_nsec))); if (ctime_nsec) - ST(10) = sv_2mortal(newSVnv(ctime + 1e-9 * (NV) ctime_nsec)); + ST(10) = sv_2mortal(newSVnv(UV2NV(ctime) + 1e-9 * UV2NV(ctime_nsec))); } XSRETURN(nret); diff --git a/dist/Math-BigInt-FastCalc/FastCalc.xs b/dist/Math-BigInt-FastCalc/FastCalc.xs index a045c71..c8a75e1 100644 --- a/dist/Math-BigInt-FastCalc/FastCalc.xs +++ b/dist/Math-BigInt-FastCalc/FastCalc.xs @@ -59,10 +59,11 @@ _new(class, x) STRLEN len; char* cur; STRLEN part_len; + UV uv; AV *av = newAV(); CODE: - if (SvUOK(x) && SvUV(x) < XS_BASE) + if (SvUOK(x) && ((uv=SvUV(x)), UV2NV(uv)) < XS_BASE) { /* shortcut for integer arguments */ av_push (av, newSVuv( SvUV(x) )); diff --git a/handy.h b/handy.h index 6b74c87..75d27b5 100644 --- a/handy.h +++ b/handy.h @@ -183,12 +183,10 @@ typedef I16TYPE I16; typedef U16TYPE U16; typedef I32TYPE I32; typedef U32TYPE U32; -#ifdef PERL_CORE -# ifdef HAS_QUAD +#ifdef HAS_QUAD typedef I64TYPE I64; typedef U64TYPE U64; -# endif -#endif /* PERL_CORE */ +#endif #if defined(HAS_QUAD) && defined(USE_64_BIT_INT) # if defined(HAS_LONG_LONG) && QUADKIND == QUAD_IS_LONG_LONG diff --git a/hv_func.h b/hv_func.h index 191912a..55f8811 100644 --- a/hv_func.h +++ b/hv_func.h @@ -132,7 +132,7 @@ #endif /* Find best way to ROTL32/ROTL64 */ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER >= 1300 #include /* Microsoft put _rotl declaration in here */ #define ROTL32(x,r) _rotl(x,r) #ifdef HAS_QUAD @@ -192,10 +192,10 @@ PERL_STATIC_INLINE U32 S_perl_hash_siphash_2_4(const unsigned char * const seed, const unsigned char *in, const STRLEN inlen) { /* "somepseudorandomlygeneratedbytes" */ - U64TYPE v0 = 0x736f6d6570736575ULL; - U64TYPE v1 = 0x646f72616e646f6dULL; - U64TYPE v2 = 0x6c7967656e657261ULL; - U64TYPE v3 = 0x7465646279746573ULL; + U64TYPE v0 = U64_CONST(0x736f6d6570736575); + U64TYPE v1 = U64_CONST(0x646f72616e646f6d); + U64TYPE v2 = U64_CONST(0x6c7967656e657261); + U64TYPE v3 = U64_CONST(0x7465646279746573); U64TYPE b; U64TYPE k0 = ((U64TYPE*)seed)[0]; diff --git a/numeric.c b/numeric.c index d431728..1158ec3 100644 --- a/numeric.c +++ b/numeric.c @@ -184,7 +184,7 @@ Perl_grok_bin(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) Perl_ck_warner_d(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in binary number"); overflowed = TRUE; - value_nv = (NV) value; + value_nv = UV2NV(value); } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to @@ -306,7 +306,7 @@ Perl_grok_hex(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) Perl_ck_warner_d(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in hexadecimal number"); overflowed = TRUE; - value_nv = (NV) value; + value_nv = UV2NV(value); } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to @@ -409,7 +409,7 @@ Perl_grok_oct(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) Perl_ck_warner_d(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in octal number"); overflowed = TRUE; - value_nv = (NV) value; + value_nv = UV2NV(value); } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to @@ -484,7 +484,7 @@ Perl_scan_bin(pTHX_ const char *start, STRLEN len, STRLEN *retlen) PERL_ARGS_ASSERT_SCAN_BIN; *retlen = len; - return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : (NV)ruv; + return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : UV2NV(ruv); } NV @@ -497,7 +497,7 @@ Perl_scan_oct(pTHX_ const char *start, STRLEN len, STRLEN *retlen) PERL_ARGS_ASSERT_SCAN_OCT; *retlen = len; - return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : (NV)ruv; + return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : UV2NV(ruv); } NV @@ -510,7 +510,7 @@ Perl_scan_hex(pTHX_ const char *start, STRLEN len, STRLEN *retlen) PERL_ARGS_ASSERT_SCAN_HEX; *retlen = len; - return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : (NV)ruv; + return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : UV2NV(ruv); } /* @@ -1011,7 +1011,7 @@ Perl_my_atof2(pTHX_ const char* orig, NV* value) /* add accumulator to result and start again */ result[seen_dp] = S_mulexp10(result[seen_dp], exp_acc[seen_dp]) - + (NV)accumulator[seen_dp]; + + UV2NV(accumulator[seen_dp]); accumulator[seen_dp] = 0; exp_acc[seen_dp] = 0; } @@ -1033,9 +1033,9 @@ Perl_my_atof2(pTHX_ const char* orig, NV* value) } } - result[0] = S_mulexp10(result[0], exp_acc[0]) + (NV)accumulator[0]; + result[0] = S_mulexp10(result[0], exp_acc[0]) + UV2NV(accumulator[0]); if (seen_dp) { - result[1] = S_mulexp10(result[1], exp_acc[1]) + (NV)accumulator[1]; + result[1] = S_mulexp10(result[1], exp_acc[1]) + UV2NV(accumulator[1]); } if (seen_digit && (*s == 'e' || *s == 'E')) { diff --git a/perl.h b/perl.h index 26902eb..23410b4 100644 --- a/perl.h +++ b/perl.h @@ -754,6 +754,20 @@ EXTERN_C int syscall(int, ...); EXTERN_C int usleep(unsigned int); #endif +# ifdef HAS_QUAD +# if INTSIZE >= 8 +# define U64_CONST(x) ((U64)x##U) +# elif LONGSIZE >= 8 +# define U64_CONST(x) ((U64)x##UL) +# elif QUADKIND == QUAD_IS_LONG_LONG +# define U64_CONST(x) ((U64)x##ULL) +# elif QUADKIND == QUAD_IS___INT64 +# define U64_CONST(x) ((U64)x##UI64) +# else /* best guess we can make */ +# define U64_CONST(x) ((U64)x##UL) +# endif +# endif + #ifdef PERL_CORE /* macros for correct constant construction */ @@ -769,19 +783,6 @@ EXTERN_C int usleep(unsigned int); # define U32_CONST(x) ((U32)x##UL) # endif -# ifdef HAS_QUAD -# if INTSIZE >= 8 -# define U64_CONST(x) ((U64)x##U) -# elif LONGSIZE >= 8 -# define U64_CONST(x) ((U64)x##UL) -# elif QUADKIND == QUAD_IS_LONG_LONG -# define U64_CONST(x) ((U64)x##ULL) -# elif QUADKIND == QUAD_IS___INT64 -# define U64_CONST(x) ((U64)x##UI64) -# else /* best guess we can make */ -# define U64_CONST(x) ((U64)x##UL) -# endif -# endif /* byte-swapping functions for big-/little-endian conversion */ # define _swab_16_(x) ((U16)( \ @@ -3495,6 +3496,12 @@ my_swap16(const U16 x) { #define U_S(what) ((U16)U_32(what)) #define U_I(what) ((unsigned int)U_32(what)) #define U_L(what) U_32(what) +#if defined(_MSC_VER) && _MSC_VER < 1300 && UVSIZE == 8 +# define UV2NV(x) ((NV)(I64)((x) & U64_CONST(0x7FFFFFFFFFFFFFFF)) + -(NV)(I64)((x) & U64_CONST(0x8000000000000000))) +#else +# define UV2NV(x) ((NV)(x)) +#endif + #ifdef HAS_SIGNBIT # define Perl_signbit signbit diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 735f8e6..afa58b6 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -380,6 +380,12 @@ In over a decade we have received no bug reports about this, hence it is clear that no-one is using this functionality on any version of Perl that is still supported to any degree. +=item support for USE_64_BIT_INT on Visual C++ 6 added + +Support has been added for the USE_64_BIT_INT build option on Visual C++ 6. +Previously USE_64_BIT_INT was not available with Visual C++ 6, only compilers +newer than Visual C++ 6. + =back =head2 New Platforms diff --git a/pp.c b/pp.c index 6925f49..60e1b54 100644 --- a/pp.c +++ b/pp.c @@ -1146,7 +1146,7 @@ PP(pp_pow) And powers of 2 are the favourite thing for perl programmers to notice ** not doing what they mean. */ NV result = 1.0; - NV base = baseuok ? baseuv : -(NV)baseuv; + NV base = baseuok ? UV2NV(baseuv) : -UV2NV(baseuv); if (power & 1) { result *= base; @@ -1198,7 +1198,7 @@ PP(pp_pow) SETi( IV_MIN ); else /* answer negative, doesn't fit */ - SETn( -(NV)result ); + SETn( -UV2NV(result) ); RETURN; } } @@ -1478,7 +1478,7 @@ PP(pp_divide) SETi( -(IV)result ); else { /* It's exact but too negative for IV. */ - SETn( -(NV)result ); + SETn( -UV2NV(result) ); } RETURN; } /* tried integer divide but it was not an integer result */ @@ -1584,7 +1584,7 @@ PP(pp_modulo) if (dright_valid) dright = Perl_floor(dright + 0.5); else - dright = right; + dright = UV2NV(right); } } } @@ -1617,7 +1617,7 @@ PP(pp_modulo) if (ans <= ~((UV)IV_MAX)+1) sv_setiv(TARG, ~ans+1); else - sv_setnv(TARG, -(NV)ans); + sv_setnv(TARG, -UV2NV(ans)); } else sv_setuv(TARG, ans); @@ -1864,7 +1864,7 @@ PP(pp_subtract) SETi( -(IV)result ); else { /* result valid, but out of range for IV. */ - SETn( -(NV)result ); + SETn( -UV2NV(result) ); } } RETURN; diff --git a/pp_hot.c b/pp_hot.c index 31b6530..6f37be6 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -698,7 +698,7 @@ PP(pp_add) SETi( -(IV)result ); else { /* result valid, but out of range for IV. */ - SETn( -(NV)result ); + SETn( -UV2NV(result) ); } } RETURN; diff --git a/pp_pack.c b/pp_pack.c index 3aa7a73..470f238 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -1270,7 +1270,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c if (!checksum) mPUSHu(val); else if (checksum > bits_in_uv) - cdouble += (NV) val; + cdouble += UV2NV(val); else cuv += val; } @@ -1327,7 +1327,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c if (!checksum) mPUSHu(auv); else if (checksum > bits_in_uv) - cdouble += (NV) auv; + cdouble += UV2NV(auv); else cuv += auv; } @@ -1473,7 +1473,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c if (!checksum) mPUSHu(auv); else if (checksum > bits_in_uv) - cdouble += (NV)auv; + cdouble += UV2NV(auv); else cuv += auv; } @@ -1652,9 +1652,9 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c SHIFT_VAR(utf8, s, strend, auquad, datumtype, needs_swap); if (!checksum) mPUSHs(auquad <= UV_MAX ? - newSVuv((UV)auquad) : newSVnv((NV)auquad)); + newSVuv((UV)auquad) : newSVnv(UV2NV(auquad))); else if (checksum > bits_in_uv) - cdouble += (NV)auquad; + cdouble += UV2NV(auquad); else cuv += auquad; } diff --git a/sv.c b/sv.c index d6d61a6..25d26bf 100644 --- a/sv.c +++ b/sv.c @@ -2002,7 +2002,7 @@ S_sv_2iuv_non_preserve(pTHX_ SV *const sv } SvIsUV_on(sv); SvUV_set(sv, U_V(SvNVX(sv))); - if ((NV)(SvUVX(sv)) == SvNVX(sv)) { + if (UV2NV(SvUVX(sv)) == SvNVX(sv)) { if (SvUVX(sv) == UV_MAX) { /* As we know that NVs don't preserve UVs, UV_MAX cannot possibly be preserved by NV. Hence, it must be overflow. @@ -2091,7 +2091,7 @@ S_sv_2iuv_common(pTHX_ SV *const sv) else { SvUV_set(sv, U_V(SvNVX(sv))); if ( - (SvNVX(sv) == (NV) SvUVX(sv)) + (SvNVX(sv) == UV2NV(SvUVX(sv))) #ifndef NV_PRESERVES_UV /* Make sure it's not 0xFFFFFFFFFFFFFFFF */ /*&& (SvUVX(sv) != UV_MAX) irrelevant with code below */ @@ -2169,7 +2169,7 @@ S_sv_2iuv_common(pTHX_ SV *const sv) SvNOK_on(sv); SvIOK_off(sv); SvIOKp_on(sv); - SvNV_set(sv, -(NV)value); + SvNV_set(sv, -UV2NV(value)); SvIV_set(sv, IV_MIN); } } @@ -2500,7 +2500,7 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags) } if (SvIOKp(sv)) { if (SvIsUV(sv)) - return (NV)SvUVX(sv); + return UV2NV(SvUVX(sv)); else return (NV)SvIVX(sv); } @@ -2565,7 +2565,7 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags) return SvNVX(sv); } if (SvIOKp(sv)) { - SvNV_set(sv, SvIsUV(sv) ? (NV)SvUVX(sv) : (NV)SvIVX(sv)); + SvNV_set(sv, SvIsUV(sv) ? UV2NV(SvUVX(sv)) : (NV)SvIVX(sv)); #ifdef NV_PRESERVES_UV if (SvIOK(sv)) SvNOK_on(sv); @@ -10405,7 +10405,7 @@ S_F0convert(NV nv, char *const endbuf, STRLEN *const len) char *p = endbuf; nv += 0.5; uv = (UV)nv; - if (uv & 1 && uv == nv) + if (uv & 1 && UV2NV(uv) == nv) uv--; /* Round to even */ do { const unsigned dig = uv % 10; diff --git a/toke.c b/toke.c index f8ebf53..58681b1 100644 --- a/toke.c +++ b/toke.c @@ -2364,7 +2364,7 @@ Perl_str_to_version(pTHX_ SV *sv) n = *(U8*)start; skip = 1; } - retval += ((NV)n)/nshift; + retval += (UV2NV(n))/nshift; start += skip; nshift *= 1000; } @@ -11121,7 +11121,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) if ((x >> shift) != u && !(PL_hints & HINT_NEW_BINARY)) { overflowed = TRUE; - n = (NV) u; + n = UV2NV(u); Perl_ck_warner_d(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in %s number", base); @@ -11138,7 +11138,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) * remember when did we overflow and in the * end just multiply n by the right * amount. */ - n += (NV) b; + n += UV2NV(b); } break; } diff --git a/win32/Makefile b/win32/Makefile index 4d2a6d9..3dcce36 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -96,7 +96,6 @@ USE_LARGE_FILES = define # Uncomment this if you're building a 32-bit perl and want 64-bit integers. # (If you're building a 64-bit perl then you will have 64-bit integers whether # or not this is uncommented.) -# Note: This option is not supported in 32-bit MSVC60 builds. USE_64_BIT_INT = define # @@ -336,13 +335,6 @@ USE_64_BIT_INT = define CCTYPE = SDK2003SP1 !ENDIF -# Disable the 64-bit-int option for (32-bit) MSVC60 builds since that compiler -# does not support it. -!IF "$(CCTYPE)" == "MSVC60" -!UNDEF USE_64_BIT_INT -USE_64_BIT_INT = undef -!ENDIF - # Most relevant compiler-specific options fall into two groups: # either pre-MSVC80 or MSVC80 onwards, so define a macro for this. !IF "$(CCTYPE)" == "MSVC60" || \ diff --git a/win32/makefile.mk b/win32/makefile.mk index 25148d8..9550da6 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -102,7 +102,6 @@ USE_LARGE_FILES *= define # Uncomment this if you're building a 32-bit perl and want 64-bit integers. # (If you're building a 64-bit perl then you will have 64-bit integers whether # or not this is uncommented.) -# Note: This option is not supported in 32-bit MSVC60 builds. #USE_64_BIT_INT *= define # @@ -345,12 +344,6 @@ USE_64_BIT_INT = define CCTYPE = SDK2003SP1 .ENDIF -# Disable the 64-bit-int option for (32-bit) MSVC60 builds since that compiler -# does not support it. -.IF "$(CCTYPE)" == "MSVC60" -USE_64_BIT_INT != undef -.ENDIF - ARCHITECTURE = $(PROCESSOR_ARCHITECTURE) .IF "$(ARCHITECTURE)" == "AMD64" ARCHITECTURE = x64 -- 1.7.9.msysgit.0 ```
p5pRT commented 10 years ago

From @bulk88

On Fri Jan 17 21​:43​:40 2014\, bulk88 wrote​:

This is a bug report for perl from bulk88@​hotmail.com\, generated with the help of perlbug 1.39 running under perl 5.19.7.

----------------------------------------------------------------- [Please describe your issue here]

See attached patch. This is a WIP. Comments requested. No comments on murdering VC6 please. Patching the CPAN stuff I'm not sure how arrange the logistics of\, since it requires a new macro\, but also backcompat with older perls.


../lib/vars.t ..................................................... ok ../lib/vars_carp.t ................................................ ok ../lib/vmsish.t ................................................... ok ../lib/warnings.t ................................................. ok x2p/find2perl.t ................................................... skipped​: Nee d something vaguely POSIX x2p/s2p.t ......................................................... ok

Test Summary Report


porting/cmp_version.t (Wstat​: 0 Tests​: 30 Failed​: 1)   Failed test​: 15 porting/podcheck.t (Wstat​: 0 Tests​: 1372 Failed​: 2)   Failed tests​: 176\, 953 Files=2380\, Tests=693347\, 3829 wallclock secs (136.80 usr + 5.81 sys = 142.61 C PU) Result​: FAIL NMAKE : fatal error U1077​: '..\perl.exe' : return code '0x3' Stop.

C​:\perl519\src\win32>..\perl -Ilib -V Summary of my perl5 (revision 5 version 19 subversion 8) configuration​:   Derived from​: c57317626f225ab9dcb96d5e821be4120370c54d   Ancestor​: a461c2333c824cbda4d43202743a566c80f6e912   Platform​:   osname=MSWin32\, osvers=5.1\, archname=MSWin32-x86-multi-thread-64int   uname=''   config_args='undef'   hint=recommended\, useposix=true\, d_sigaction=undef   useithreads=define\, usemultiplicity=define   use64bitint=define\, use64bitall=undef\, uselongdouble=undef   usemymalloc=n\, bincompat5005=undef   Compiler​:   cc='cl'\, ccflags ='-nologo -GF -W3 -Od -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE - DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPERL_HASH_FUNC_ONE_AT_A_TIME -DPERL_IMPLIC IT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T'\,   optimize='-Od -MD -Zi -DNDEBUG'\,   cppflags='-DWIN32'   ccversion='12.00.8168'\, gccversion=''\, gccosandvers=''   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=12345678   d_longlong=undef\, longlongsize=8\, d_longdbl=define\, longdblsize=8   ivtype='__int64'\, ivsize=8\, nvtype='double'\, nvsize=8\, Off_t='__int64'\, lsee ksize=8   alignbytes=8\, prototype=define   Linker and Libraries​:   ld='link'\, ldflags ='-nologo -nodefaultlib -debug -opt​:ref\,icf -libpath​:"c​: \perl519\lib\CORE" -machine​:x86'   libpth=C​:\PROGRA~1\MIAF9D~1\VC98\lib   libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.l ib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32 .lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt. lib   perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg 32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws 2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msv crt.lib   libc=msvcrt.lib\, so=dll\, useshrplib=true\, libperl=perl519.lib   gnulibc_version=''   Dynamic Linking​:   dlsrc=dl_win32.xs\, dlext=dll\, d_dlsymun=undef\, ccdlflags=' '   cccdlflags=' '\, lddlflags='-dll -nologo -nodefaultlib -debug -opt​:ref\,icf - libpath​:"c​:\perl519\lib\CORE" -machine​:x86'

Characteristics of this binary (from libperl)​:   Compile-time options​: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY   PERLIO_LAYERS PERL_DONT_CREATE_GVSV   PERL_HASH_FUNC_ONE_AT_A_TIME PERL_IMPLICIT_CONTEXT   PERL_IMPLICIT_SYS PERL_MALLOC_WRAP   PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV   USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES   USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE   USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF   Locally applied patches​:   uncommitted-changes   c57317626f225ab9dcb96d5e821be4120370c54d   Built under MSWin32   Compiled at Jan 17 2014 23​:31​:45   @​INC​:   lib   C​:/perl519/src/lib   .

C​:\perl519\src\win32>cl /? Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

  C/C++ COMPILER OPTIONS


Smoke looks good. I do realize the UV2NV macro requirement makes many XS modules on CPAN with VC6 not build\, so that disclaimer will probably have to go into README.win32.

-- bulk88 ~ bulk88 at hotmail.com

p5pRT commented 10 years ago

From @bulk88

Some fixes in the patch. Clearer notes about the limitations of VC6 and 64 bit IVs. 1 cmp_version fix.

-- bulk88 ~ bulk88 at hotmail.com

p5pRT commented 10 years ago

From @bulk88

0001-WIP-enable-USE_64_BIT_INT-for-Visual-C-6-ver-2.patch ```diff From 294e3e2158af8414135be27cc98d123fc7c5b61f Mon Sep 17 00:00:00 2001 From: Daniel Dragan Date: Mon, 20 Jan 2014 14:03:12 -0500 Subject: [PATCH] WIP enable USE_64_BIT_INT for Visual C 6 ver 2 --- README.win32 | 5 ++- cpan/Encode/Encode.xs | 2 +- cpan/Scalar-List-Utils/ListUtil.xs | 2 +- cpan/Time-HiRes/HiRes.xs | 8 ++-- dist/Math-BigInt-FastCalc/FastCalc.xs | 3 +- .../lib/Math/BigInt/FastCalc.pm | 2 +- handy.h | 6 +-- hv_func.h | 10 +++--- numeric.c | 18 +++++----- perl.h | 33 ++++++++++++-------- pod/perldelta.pod | 7 ++++ pp.c | 12 +++--- pp_hot.c | 2 +- pp_pack.c | 10 +++--- sv.c | 12 +++--- toke.c | 6 ++-- win32/Makefile | 10 +----- win32/makefile.mk | 9 +---- 18 files changed, 80 insertions(+), 77 deletions(-) diff --git a/README.win32 b/README.win32 index e19b48c..a9f33e0 100644 --- a/README.win32 +++ b/README.win32 @@ -373,8 +373,9 @@ the linker reports an internal error. If you want build some core extensions statically into perl's dll, specify them in the STATIC_EXT macro. -NOTE: The USE_64_BIT_INT build option is not supported with the 32-bit -Visual C++ 6.0 compiler. +NOTE: When using the 32-bit Visual C++ 6.0 compiler and the USE_64_BIT_INT +build option, the result is very poor compatibility with CPAN modules that use +XS. Newer versions of Visual C++ do not have this problem. Be sure to read the instructions near the top of the makefiles carefully. diff --git a/cpan/Encode/Encode.xs b/cpan/Encode/Encode.xs index ea9265f..854e2cd 100644 --- a/cpan/Encode/Encode.xs +++ b/cpan/Encode/Encode.xs @@ -77,7 +77,7 @@ do_fallback_cb(pTHX_ UV ch, SV *fallback_cb) ENTER; SAVETMPS; PUSHMARK(sp); - XPUSHs(sv_2mortal(newSVnv((UV)ch))); + XPUSHs(sv_2mortal(newSVnv(UV2NV(ch)))) ; PUTBACK; argc = call_sv(fallback_cb, G_SCALAR); SPAGAIN; diff --git a/cpan/Scalar-List-Utils/ListUtil.xs b/cpan/Scalar-List-Utils/ListUtil.xs index af869ce..9e1d9f5 100644 --- a/cpan/Scalar-List-Utils/ListUtil.xs +++ b/cpan/Scalar-List-Utils/ListUtil.xs @@ -53,7 +53,7 @@ my_sv_copypv(pTHX_ SV *const dsv, SV *const ssv) #endif #ifdef SVf_IVisUV -# define slu_sv_value(sv) (SvIOK(sv)) ? (SvIOK_UV(sv)) ? (NV)(SvUVX(sv)) : (NV)(SvIVX(sv)) : (SvNV(sv)) +# define slu_sv_value(sv) (SvIOK(sv)) ? (SvIOK_UV(sv)) ? UV2NV(SvUVX(sv)) : (NV)(SvIVX(sv)) : (SvNV(sv)) #else # define slu_sv_value(sv) (SvIOK(sv)) ? (NV)(SvIVX(sv)) : (SvNV(sv)) #endif diff --git a/cpan/Time-HiRes/HiRes.xs b/cpan/Time-HiRes/HiRes.xs index 96640e9..f419bc7 100644 --- a/cpan/Time-HiRes/HiRes.xs +++ b/cpan/Time-HiRes/HiRes.xs @@ -874,7 +874,7 @@ sleep(...) if (items > 0) { NV seconds = SvNV(ST(0)); if (seconds >= 0.0) { - UV useconds = (UV)(1E6 * (seconds - (UV)seconds)); + UV useconds = (UV)(1E6 * (seconds - UV2NV((UV)seconds))); if (seconds >= 1.0) sleep((U32)seconds); if ((IV)useconds < 0) { @@ -1297,10 +1297,10 @@ PROTOTYPE: ;$ UV ctime_nsec; hrstatns(&atime_nsec, &mtime_nsec, &ctime_nsec); if (atime_nsec) - ST( 8) = sv_2mortal(newSVnv(atime + 1e-9 * (NV) atime_nsec)); + ST( 8) = sv_2mortal(newSVnv(UV2NV(atime) + 1e-9 * UV2NV(atime_nsec))); if (mtime_nsec) - ST( 9) = sv_2mortal(newSVnv(mtime + 1e-9 * (NV) mtime_nsec)); + ST( 9) = sv_2mortal(newSVnv(UV2NV(mtime) + 1e-9 * UV2NV(mtime_nsec))); if (ctime_nsec) - ST(10) = sv_2mortal(newSVnv(ctime + 1e-9 * (NV) ctime_nsec)); + ST(10) = sv_2mortal(newSVnv(UV2NV(ctime) + 1e-9 * UV2NV(ctime_nsec))); } XSRETURN(nret); diff --git a/dist/Math-BigInt-FastCalc/FastCalc.xs b/dist/Math-BigInt-FastCalc/FastCalc.xs index a045c71..c8a75e1 100644 --- a/dist/Math-BigInt-FastCalc/FastCalc.xs +++ b/dist/Math-BigInt-FastCalc/FastCalc.xs @@ -59,10 +59,11 @@ _new(class, x) STRLEN len; char* cur; STRLEN part_len; + UV uv; AV *av = newAV(); CODE: - if (SvUOK(x) && SvUV(x) < XS_BASE) + if (SvUOK(x) && ((uv=SvUV(x)), UV2NV(uv)) < XS_BASE) { /* shortcut for integer arguments */ av_push (av, newSVuv( SvUV(x) )); diff --git a/dist/Math-BigInt-FastCalc/lib/Math/BigInt/FastCalc.pm b/dist/Math-BigInt-FastCalc/lib/Math/BigInt/FastCalc.pm index 9bf5a60..faa69f6 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.31'; +$VERSION = '0.32'; ############################################################################## # global constants, flags and accessory diff --git a/handy.h b/handy.h index 6b74c87..75d27b5 100644 --- a/handy.h +++ b/handy.h @@ -183,12 +183,10 @@ typedef I16TYPE I16; typedef U16TYPE U16; typedef I32TYPE I32; typedef U32TYPE U32; -#ifdef PERL_CORE -# ifdef HAS_QUAD +#ifdef HAS_QUAD typedef I64TYPE I64; typedef U64TYPE U64; -# endif -#endif /* PERL_CORE */ +#endif #if defined(HAS_QUAD) && defined(USE_64_BIT_INT) # if defined(HAS_LONG_LONG) && QUADKIND == QUAD_IS_LONG_LONG diff --git a/hv_func.h b/hv_func.h index 191912a..55f8811 100644 --- a/hv_func.h +++ b/hv_func.h @@ -132,7 +132,7 @@ #endif /* Find best way to ROTL32/ROTL64 */ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER >= 1300 #include /* Microsoft put _rotl declaration in here */ #define ROTL32(x,r) _rotl(x,r) #ifdef HAS_QUAD @@ -192,10 +192,10 @@ PERL_STATIC_INLINE U32 S_perl_hash_siphash_2_4(const unsigned char * const seed, const unsigned char *in, const STRLEN inlen) { /* "somepseudorandomlygeneratedbytes" */ - U64TYPE v0 = 0x736f6d6570736575ULL; - U64TYPE v1 = 0x646f72616e646f6dULL; - U64TYPE v2 = 0x6c7967656e657261ULL; - U64TYPE v3 = 0x7465646279746573ULL; + U64TYPE v0 = U64_CONST(0x736f6d6570736575); + U64TYPE v1 = U64_CONST(0x646f72616e646f6d); + U64TYPE v2 = U64_CONST(0x6c7967656e657261); + U64TYPE v3 = U64_CONST(0x7465646279746573); U64TYPE b; U64TYPE k0 = ((U64TYPE*)seed)[0]; diff --git a/numeric.c b/numeric.c index d431728..1158ec3 100644 --- a/numeric.c +++ b/numeric.c @@ -184,7 +184,7 @@ Perl_grok_bin(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) Perl_ck_warner_d(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in binary number"); overflowed = TRUE; - value_nv = (NV) value; + value_nv = UV2NV(value); } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to @@ -306,7 +306,7 @@ Perl_grok_hex(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) Perl_ck_warner_d(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in hexadecimal number"); overflowed = TRUE; - value_nv = (NV) value; + value_nv = UV2NV(value); } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to @@ -409,7 +409,7 @@ Perl_grok_oct(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) Perl_ck_warner_d(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in octal number"); overflowed = TRUE; - value_nv = (NV) value; + value_nv = UV2NV(value); } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to @@ -484,7 +484,7 @@ Perl_scan_bin(pTHX_ const char *start, STRLEN len, STRLEN *retlen) PERL_ARGS_ASSERT_SCAN_BIN; *retlen = len; - return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : (NV)ruv; + return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : UV2NV(ruv); } NV @@ -497,7 +497,7 @@ Perl_scan_oct(pTHX_ const char *start, STRLEN len, STRLEN *retlen) PERL_ARGS_ASSERT_SCAN_OCT; *retlen = len; - return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : (NV)ruv; + return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : UV2NV(ruv); } NV @@ -510,7 +510,7 @@ Perl_scan_hex(pTHX_ const char *start, STRLEN len, STRLEN *retlen) PERL_ARGS_ASSERT_SCAN_HEX; *retlen = len; - return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : (NV)ruv; + return (flags & PERL_SCAN_GREATER_THAN_UV_MAX) ? rnv : UV2NV(ruv); } /* @@ -1011,7 +1011,7 @@ Perl_my_atof2(pTHX_ const char* orig, NV* value) /* add accumulator to result and start again */ result[seen_dp] = S_mulexp10(result[seen_dp], exp_acc[seen_dp]) - + (NV)accumulator[seen_dp]; + + UV2NV(accumulator[seen_dp]); accumulator[seen_dp] = 0; exp_acc[seen_dp] = 0; } @@ -1033,9 +1033,9 @@ Perl_my_atof2(pTHX_ const char* orig, NV* value) } } - result[0] = S_mulexp10(result[0], exp_acc[0]) + (NV)accumulator[0]; + result[0] = S_mulexp10(result[0], exp_acc[0]) + UV2NV(accumulator[0]); if (seen_dp) { - result[1] = S_mulexp10(result[1], exp_acc[1]) + (NV)accumulator[1]; + result[1] = S_mulexp10(result[1], exp_acc[1]) + UV2NV(accumulator[1]); } if (seen_digit && (*s == 'e' || *s == 'E')) { diff --git a/perl.h b/perl.h index 26902eb..23410b4 100644 --- a/perl.h +++ b/perl.h @@ -754,6 +754,20 @@ EXTERN_C int syscall(int, ...); EXTERN_C int usleep(unsigned int); #endif +# ifdef HAS_QUAD +# if INTSIZE >= 8 +# define U64_CONST(x) ((U64)x##U) +# elif LONGSIZE >= 8 +# define U64_CONST(x) ((U64)x##UL) +# elif QUADKIND == QUAD_IS_LONG_LONG +# define U64_CONST(x) ((U64)x##ULL) +# elif QUADKIND == QUAD_IS___INT64 +# define U64_CONST(x) ((U64)x##UI64) +# else /* best guess we can make */ +# define U64_CONST(x) ((U64)x##UL) +# endif +# endif + #ifdef PERL_CORE /* macros for correct constant construction */ @@ -769,19 +783,6 @@ EXTERN_C int usleep(unsigned int); # define U32_CONST(x) ((U32)x##UL) # endif -# ifdef HAS_QUAD -# if INTSIZE >= 8 -# define U64_CONST(x) ((U64)x##U) -# elif LONGSIZE >= 8 -# define U64_CONST(x) ((U64)x##UL) -# elif QUADKIND == QUAD_IS_LONG_LONG -# define U64_CONST(x) ((U64)x##ULL) -# elif QUADKIND == QUAD_IS___INT64 -# define U64_CONST(x) ((U64)x##UI64) -# else /* best guess we can make */ -# define U64_CONST(x) ((U64)x##UL) -# endif -# endif /* byte-swapping functions for big-/little-endian conversion */ # define _swab_16_(x) ((U16)( \ @@ -3495,6 +3496,12 @@ my_swap16(const U16 x) { #define U_S(what) ((U16)U_32(what)) #define U_I(what) ((unsigned int)U_32(what)) #define U_L(what) U_32(what) +#if defined(_MSC_VER) && _MSC_VER < 1300 && UVSIZE == 8 +# define UV2NV(x) ((NV)(I64)((x) & U64_CONST(0x7FFFFFFFFFFFFFFF)) + -(NV)(I64)((x) & U64_CONST(0x8000000000000000))) +#else +# define UV2NV(x) ((NV)(x)) +#endif + #ifdef HAS_SIGNBIT # define Perl_signbit signbit diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 735f8e6..9667080 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -380,6 +380,13 @@ In over a decade we have received no bug reports about this, hence it is clear that no-one is using this functionality on any version of Perl that is still supported to any degree. +=item support for USE_64_BIT_INT on Visual C++ 6 added + +Support has been added for the USE_64_BIT_INT build option on Visual C++ 6. +Previously USE_64_BIT_INT was not available with Visual C++ 6, only compilers +newer than Visual C++ 6. Using USE_64_BIT_INT with Visual C++ 6 (but not newer) +results in limited compatibility with CPAN XS-using modules. + =back =head2 New Platforms diff --git a/pp.c b/pp.c index 6925f49..60e1b54 100644 --- a/pp.c +++ b/pp.c @@ -1146,7 +1146,7 @@ PP(pp_pow) And powers of 2 are the favourite thing for perl programmers to notice ** not doing what they mean. */ NV result = 1.0; - NV base = baseuok ? baseuv : -(NV)baseuv; + NV base = baseuok ? UV2NV(baseuv) : -UV2NV(baseuv); if (power & 1) { result *= base; @@ -1198,7 +1198,7 @@ PP(pp_pow) SETi( IV_MIN ); else /* answer negative, doesn't fit */ - SETn( -(NV)result ); + SETn( -UV2NV(result) ); RETURN; } } @@ -1478,7 +1478,7 @@ PP(pp_divide) SETi( -(IV)result ); else { /* It's exact but too negative for IV. */ - SETn( -(NV)result ); + SETn( -UV2NV(result) ); } RETURN; } /* tried integer divide but it was not an integer result */ @@ -1584,7 +1584,7 @@ PP(pp_modulo) if (dright_valid) dright = Perl_floor(dright + 0.5); else - dright = right; + dright = UV2NV(right); } } } @@ -1617,7 +1617,7 @@ PP(pp_modulo) if (ans <= ~((UV)IV_MAX)+1) sv_setiv(TARG, ~ans+1); else - sv_setnv(TARG, -(NV)ans); + sv_setnv(TARG, -UV2NV(ans)); } else sv_setuv(TARG, ans); @@ -1864,7 +1864,7 @@ PP(pp_subtract) SETi( -(IV)result ); else { /* result valid, but out of range for IV. */ - SETn( -(NV)result ); + SETn( -UV2NV(result) ); } } RETURN; diff --git a/pp_hot.c b/pp_hot.c index 31b6530..6f37be6 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -698,7 +698,7 @@ PP(pp_add) SETi( -(IV)result ); else { /* result valid, but out of range for IV. */ - SETn( -(NV)result ); + SETn( -UV2NV(result) ); } } RETURN; diff --git a/pp_pack.c b/pp_pack.c index 3aa7a73..470f238 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -1270,7 +1270,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c if (!checksum) mPUSHu(val); else if (checksum > bits_in_uv) - cdouble += (NV) val; + cdouble += UV2NV(val); else cuv += val; } @@ -1327,7 +1327,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c if (!checksum) mPUSHu(auv); else if (checksum > bits_in_uv) - cdouble += (NV) auv; + cdouble += UV2NV(auv); else cuv += auv; } @@ -1473,7 +1473,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c if (!checksum) mPUSHu(auv); else if (checksum > bits_in_uv) - cdouble += (NV)auv; + cdouble += UV2NV(auv); else cuv += auv; } @@ -1652,9 +1652,9 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c SHIFT_VAR(utf8, s, strend, auquad, datumtype, needs_swap); if (!checksum) mPUSHs(auquad <= UV_MAX ? - newSVuv((UV)auquad) : newSVnv((NV)auquad)); + newSVuv((UV)auquad) : newSVnv(UV2NV(auquad))); else if (checksum > bits_in_uv) - cdouble += (NV)auquad; + cdouble += UV2NV(auquad); else cuv += auquad; } diff --git a/sv.c b/sv.c index d6d61a6..25d26bf 100644 --- a/sv.c +++ b/sv.c @@ -2002,7 +2002,7 @@ S_sv_2iuv_non_preserve(pTHX_ SV *const sv } SvIsUV_on(sv); SvUV_set(sv, U_V(SvNVX(sv))); - if ((NV)(SvUVX(sv)) == SvNVX(sv)) { + if (UV2NV(SvUVX(sv)) == SvNVX(sv)) { if (SvUVX(sv) == UV_MAX) { /* As we know that NVs don't preserve UVs, UV_MAX cannot possibly be preserved by NV. Hence, it must be overflow. @@ -2091,7 +2091,7 @@ S_sv_2iuv_common(pTHX_ SV *const sv) else { SvUV_set(sv, U_V(SvNVX(sv))); if ( - (SvNVX(sv) == (NV) SvUVX(sv)) + (SvNVX(sv) == UV2NV(SvUVX(sv))) #ifndef NV_PRESERVES_UV /* Make sure it's not 0xFFFFFFFFFFFFFFFF */ /*&& (SvUVX(sv) != UV_MAX) irrelevant with code below */ @@ -2169,7 +2169,7 @@ S_sv_2iuv_common(pTHX_ SV *const sv) SvNOK_on(sv); SvIOK_off(sv); SvIOKp_on(sv); - SvNV_set(sv, -(NV)value); + SvNV_set(sv, -UV2NV(value)); SvIV_set(sv, IV_MIN); } } @@ -2500,7 +2500,7 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags) } if (SvIOKp(sv)) { if (SvIsUV(sv)) - return (NV)SvUVX(sv); + return UV2NV(SvUVX(sv)); else return (NV)SvIVX(sv); } @@ -2565,7 +2565,7 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags) return SvNVX(sv); } if (SvIOKp(sv)) { - SvNV_set(sv, SvIsUV(sv) ? (NV)SvUVX(sv) : (NV)SvIVX(sv)); + SvNV_set(sv, SvIsUV(sv) ? UV2NV(SvUVX(sv)) : (NV)SvIVX(sv)); #ifdef NV_PRESERVES_UV if (SvIOK(sv)) SvNOK_on(sv); @@ -10405,7 +10405,7 @@ S_F0convert(NV nv, char *const endbuf, STRLEN *const len) char *p = endbuf; nv += 0.5; uv = (UV)nv; - if (uv & 1 && uv == nv) + if (uv & 1 && UV2NV(uv) == nv) uv--; /* Round to even */ do { const unsigned dig = uv % 10; diff --git a/toke.c b/toke.c index f8ebf53..58681b1 100644 --- a/toke.c +++ b/toke.c @@ -2364,7 +2364,7 @@ Perl_str_to_version(pTHX_ SV *sv) n = *(U8*)start; skip = 1; } - retval += ((NV)n)/nshift; + retval += (UV2NV(n))/nshift; start += skip; nshift *= 1000; } @@ -11121,7 +11121,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) if ((x >> shift) != u && !(PL_hints & HINT_NEW_BINARY)) { overflowed = TRUE; - n = (NV) u; + n = UV2NV(u); Perl_ck_warner_d(aTHX_ packWARN(WARN_OVERFLOW), "Integer overflow in %s number", base); @@ -11138,7 +11138,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) * remember when did we overflow and in the * end just multiply n by the right * amount. */ - n += (NV) b; + n += UV2NV(b); } break; } diff --git a/win32/Makefile b/win32/Makefile index 4d2a6d9..f8deee8 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -96,7 +96,8 @@ USE_LARGE_FILES = define # Uncomment this if you're building a 32-bit perl and want 64-bit integers. # (If you're building a 64-bit perl then you will have 64-bit integers whether # or not this is uncommented.) -# Note: This option is not supported in 32-bit MSVC60 builds. +# When used with MSVC60 builds only, this option results in poor CPAN XS +# compatibility. USE_64_BIT_INT = define # @@ -336,13 +337,6 @@ USE_64_BIT_INT = define CCTYPE = SDK2003SP1 !ENDIF -# Disable the 64-bit-int option for (32-bit) MSVC60 builds since that compiler -# does not support it. -!IF "$(CCTYPE)" == "MSVC60" -!UNDEF USE_64_BIT_INT -USE_64_BIT_INT = undef -!ENDIF - # Most relevant compiler-specific options fall into two groups: # either pre-MSVC80 or MSVC80 onwards, so define a macro for this. !IF "$(CCTYPE)" == "MSVC60" || \ diff --git a/win32/makefile.mk b/win32/makefile.mk index 25148d8..eb6acbb 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -102,7 +102,8 @@ USE_LARGE_FILES *= define # Uncomment this if you're building a 32-bit perl and want 64-bit integers. # (If you're building a 64-bit perl then you will have 64-bit integers whether # or not this is uncommented.) -# Note: This option is not supported in 32-bit MSVC60 builds. +# When used with MSVC60 builds only, this option results in poor CPAN XS +# compatibility. #USE_64_BIT_INT *= define # @@ -345,12 +346,6 @@ USE_64_BIT_INT = define CCTYPE = SDK2003SP1 .ENDIF -# Disable the 64-bit-int option for (32-bit) MSVC60 builds since that compiler -# does not support it. -.IF "$(CCTYPE)" == "MSVC60" -USE_64_BIT_INT != undef -.ENDIF - ARCHITECTURE = $(PROCESSOR_ARCHITECTURE) .IF "$(ARCHITECTURE)" == "AMD64" ARCHITECTURE = x64 -- 1.7.9.msysgit.0 ```
p5pRT commented 10 years ago

From @tonycoz

On Mon Jan 20 11​:10​:02 2014\, bulk88 wrote​:

Some fixes in the patch. Clearer notes about the limitations of VC6 and 64 bit IVs. 1 cmp_version fix.

I don't think this change belongs in perl.

It's working around a fairly severe breakage in a compiler for which is no longer supported by the vendor and for which free alternatives are available (MSVC as bundled with the platform SDK).

Even if applied\, this would be a ghetto in that any CPAN XS that (correctly!) expects to convert UV to NV implicitly will fail to build\, with the side effect that the user might blame the CPAN author instead of their broken tools.

Tony

p5pRT commented 10 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 10 years ago

From @tonycoz

On Sun Jan 26 15​:35​:58 2014\, tonyc wrote​:

On Mon Jan 20 11​:10​:02 2014\, bulk88 wrote​:

Some fixes in the patch. Clearer notes about the limitations of VC6 and 64 bit IVs. 1 cmp_version fix.

I don't think this change belongs in perl.

It's working around a fairly severe breakage in a compiler for which is no longer supported by the vendor and for which free alternatives are available (MSVC as bundled with the platform SDK).

Even if applied\, this would be a ghetto in that any CPAN XS that (correctly!) expects to convert UV to NV implicitly will fail to build\, with the side effect that the user might blame the CPAN author instead of their broken tools.

Per this\, I'm rejecting this patch\, thanks for submitting it though.

Tony

p5pRT commented 10 years ago

@tonycoz - Status changed from 'open' to 'rejected'