In perl.git, the branch blead has been updated <https://perl5.git.perl.org/perl.git/commitdiff/0b08cab0fc46a5f381ca18a451f55cf12c81d966?hp=a94485510cc7a65b67130a8a8c4d1065ba596a8d>
- Log ----------------------------------------------------------------- commit 0b08cab0fc46a5f381ca18a451f55cf12c81d966 Author: Karl Williamson <[email protected]> Date: Sun Jan 28 10:02:11 2018 -0700 Don't use variant_byte_number on MSVC6 See [perl #132766] commit 7cf2d6c7983ca87681477f57869bf0779d8b2604 Author: Karl Williamson <[email protected]> Date: Thu Jan 25 10:37:04 2018 -0700 inline.h: Clarify comment commit 67e12c5cdf504fc3f1a9726c0d7922ea255b22af Author: Karl Williamson <[email protected]> Date: Thu Jan 25 10:25:27 2018 -0700 Don't use C99 ULL constant suffix The suffix ULL in, e.g., 7ULL, is C99, and since perl supports C89, we can't use it. Change these occurrences to wrap those that would exceed 32 bits to use UINTMAX_C(...). perl.h has logic to define that macro appropriately if the compiler doesn't already know it. ----------------------------------------------------------------------- Summary of changes: embed.fnc | 2 +- embed.h | 6 +++--- inline.h | 24 ++++++++++++++++-------- proto.h | 14 +++++++------- regexec.c | 2 +- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/embed.fnc b/embed.fnc index c21272dffb..e16c8a65f9 100644 --- a/embed.fnc +++ b/embed.fnc @@ -806,7 +806,7 @@ AndmoR |bool |is_utf8_invariant_string|NN const U8* const s \ AnidR |bool |is_utf8_invariant_string_loc|NN const U8* const s \ |STRLEN len \ |NULLOK const U8 ** ep -#ifndef EBCDIC +#if ! defined(EBCDIC) && ! defined USING_MSVC6 AniR |unsigned int|_variant_byte_number|PERL_UINTMAX_T word #endif #if defined(PERL_CORE) || defined(PERL_EXT) diff --git a/embed.h b/embed.h index c968191616..008b8067b7 100644 --- a/embed.h +++ b/embed.h @@ -768,15 +768,15 @@ #define whichsig_sv(a) Perl_whichsig_sv(aTHX_ a) #define wrap_keyword_plugin(a,b) Perl_wrap_keyword_plugin(aTHX_ a,b) #define wrap_op_checker(a,b,c) Perl_wrap_op_checker(aTHX_ a,b,c) +#if ! defined(EBCDIC) && ! defined USING_MSVC6 +#define _variant_byte_number S__variant_byte_number +#endif #if !(defined(HAS_MEMMEM)) #define ninstr Perl_ninstr #endif #if !(defined(HAS_SIGACTION) && defined(SA_SIGINFO)) #define csighandler Perl_csighandler #endif -#if !defined(EBCDIC) -#define _variant_byte_number S__variant_byte_number -#endif #if !defined(HAS_TRUNCATE) && !defined(HAS_CHSIZE) && defined(F_FREESP) #define my_chsize(a,b) Perl_my_chsize(aTHX_ a,b) #endif diff --git a/inline.h b/inline.h index d0e2ff73a5..769e0532ac 100644 --- a/inline.h +++ b/inline.h @@ -401,6 +401,8 @@ S_is_utf8_invariant_string_loc(const U8* const s, STRLEN len, const U8 ** ep) | ( ( (PTR2nat(x) \ & PERL_WORD_BOUNDARY_MASK) >> 2)))) +# ifndef USING_MSVC6 + /* Do the word-at-a-time iff there is at least one usable full word. That * means that after advancing to a word boundary, there still is at least a * full word left. The number of bytes needed to advance is 'wordsize - @@ -458,7 +460,8 @@ S_is_utf8_invariant_string_loc(const U8* const s, STRLEN len, const U8 ** ep) } while (x + PERL_WORDSIZE <= send); } -#endif +# endif /* End of ! MSVC6 */ +#endif /* End of ! EBCDIC */ /* Process per-byte */ while (x < send) { @@ -476,7 +479,10 @@ S_is_utf8_invariant_string_loc(const U8* const s, STRLEN len, const U8 ** ep) return TRUE; } -#ifndef EBCDIC +#if ! defined(EBCDIC) && ! defined(USING_MSVC6) + +/* Apparent compiler error with MSVC6, so can't use this function. All callers + * to it must be compiled to use the EBCDIC fallback on MSVC6 */ PERL_STATIC_INLINE unsigned int S__variant_byte_number(PERL_UINTMAX_T word) @@ -544,13 +550,15 @@ S__variant_byte_number(PERL_UINTMAX_T word) # error Unexpected byte order # endif - /* Here 'word' has a single bit set, the msb is of the first byte which - * has it set. Calculate that position in the word. We can use this + /* Here 'word' has a single bit set: the msb of the first byte in which it + * is set. Calculate that position in the word. We can use this * specialized solution: https://stackoverflow.com/a/32339674/1626653, - * assumes an 8-bit byte */ - word = (word >> 7) * (( 7ULL << 56) | (15ULL << 48) | (23ULL << 40) - | (31ULL << 32) | (39ULL << 24) | (47ULL << 16) - | (55ULL << 8) | (63ULL << 0)); + * assumes an 8-bit byte. (On a 32-bit machine, the larger numbers should + * just get shifted off at compile time) */ + word = (word >> 7) * ((UINTMAX_C( 7) << 56) | (UINTMAX_C(15) << 48) + | (UINTMAX_C(23) << 40) | (UINTMAX_C(31) << 32) + | (39 << 24) | (47 << 16) + | (55 << 8) | (63 << 0)); word >>= PERL_WORDSIZE * 7; /* >> by either 56 or 24 */ /* Here, word contains the position 7..63 of that bit. Convert to 0..7 */ diff --git a/proto.h b/proto.h index 1211e57dab..911b96156c 100644 --- a/proto.h +++ b/proto.h @@ -3803,6 +3803,13 @@ PERL_CALLCONV int Perl_yylex(pTHX); PERL_CALLCONV int Perl_yyparse(pTHX_ int gramtype); PERL_CALLCONV void Perl_yyquit(pTHX); PERL_CALLCONV void Perl_yyunlex(pTHX); +#if ! defined(EBCDIC) && ! defined USING_MSVC6 +#ifndef PERL_NO_INLINE_FUNCTIONS +PERL_STATIC_INLINE unsigned int S__variant_byte_number(PERL_UINTMAX_T word) + __attribute__warn_unused_result__; +#endif + +#endif #if ! defined(HAS_MEMRCHR) && (defined(PERL_CORE) || defined(PERL_EXT)) #ifndef PERL_NO_INLINE_FUNCTIONS PERL_STATIC_INLINE void * S_my_memrchr(const char * s, const char c, const STRLEN len); @@ -3857,13 +3864,6 @@ PERL_CALLCONV_NO_RET int Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg) #define PERL_ARGS_ASSERT_MAGIC_REGDATUM_SET \ assert(sv); assert(mg) -#endif -#if !defined(EBCDIC) -#ifndef PERL_NO_INLINE_FUNCTIONS -PERL_STATIC_INLINE unsigned int S__variant_byte_number(PERL_UINTMAX_T word) - __attribute__warn_unused_result__; -#endif - #endif #if !defined(HAS_GETENV_LEN) PERL_CALLCONV char* Perl_getenv_len(pTHX_ const char *env_elem, unsigned long *len); diff --git a/regexec.c b/regexec.c index 5a1c5ef61f..530f1d6250 100644 --- a/regexec.c +++ b/regexec.c @@ -560,7 +560,7 @@ S_find_next_ascii(char * s, const char * send, const bool utf8_target) PERL_ARGS_ASSERT_FIND_NEXT_ASCII; -#ifndef EBCDIC +#if ! defined(EBCDIC) && ! defined(USING_MSVC6) if ((STRLEN) (send - s) >= PERL_WORDSIZE -- Perl5 Master Repository
