diff options
author | Norbert Preining <norbert@preining.info> | 2021-04-02 03:20:54 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-04-02 03:20:54 +0000 |
commit | 3f173002d4a4a84e7d1fa5a74755fdd00d08a9c2 (patch) | |
tree | 5ed380344702de1f9ab53b68b6c3bcd6b8458087 /systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/feature.h | |
parent | f78ba658b3ecd56053fe0837a4404d0c6c16a707 (diff) |
CTAN sync 202104020320
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/feature.h')
-rw-r--r-- | systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/feature.h | 208 |
1 files changed, 189 insertions, 19 deletions
diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/feature.h b/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/feature.h index 3877e16efe..2f2f23c4da 100644 --- a/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/feature.h +++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/feature.h @@ -12,6 +12,22 @@ #define HINT_FEATURE_SHIFT 26 +#define FEATURE_BITWISE_BIT 0x0001 +#define FEATURE___SUB___BIT 0x0002 +#define FEATURE_MYREF_BIT 0x0004 +#define FEATURE_EVALBYTES_BIT 0x0008 +#define FEATURE_FC_BIT 0x0010 +#define FEATURE_INDIRECT_BIT 0x0020 +#define FEATURE_ISA_BIT 0x0040 +#define FEATURE_POSTDEREF_QQ_BIT 0x0080 +#define FEATURE_REFALIASING_BIT 0x0100 +#define FEATURE_SAY_BIT 0x0200 +#define FEATURE_SIGNATURES_BIT 0x0400 +#define FEATURE_STATE_BIT 0x0800 +#define FEATURE_SWITCH_BIT 0x1000 +#define FEATURE_UNIEVAL_BIT 0x2000 +#define FEATURE_UNICODE_BIT 0x4000 + #define FEATURE_BUNDLE_DEFAULT 0 #define FEATURE_BUNDLE_510 1 #define FEATURE_BUNDLE_511 2 @@ -25,12 +41,10 @@ #define CURRENT_FEATURE_BUNDLE \ ((CURRENT_HINTS & HINT_FEATURE_MASK) >> HINT_FEATURE_SHIFT) -/* Avoid using ... && Perl_feature_is_enabled(...) as that triggers a bug in - the HP-UX cc on PA-RISC */ -#define FEATURE_IS_ENABLED(name) \ - ((CURRENT_HINTS \ - & HINT_LOCALIZE_HH) \ - ? Perl_feature_is_enabled(aTHX_ STR_WITH_LEN(name)) : FALSE) +#define FEATURE_IS_ENABLED_MASK(mask) \ + ((CURRENT_HINTS & HINT_LOCALIZE_HH) \ + ? (PL_curcop->cop_features & (mask)) : FALSE) + /* The longest string we pass in. */ #define MAX_FEATURE_LEN (sizeof("postderef_qq")-1) @@ -39,7 +53,13 @@ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \ CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("fc")) \ + FEATURE_IS_ENABLED_MASK(FEATURE_FC_BIT)) \ + ) + +#define FEATURE_ISA_IS_ENABLED \ + ( \ + CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ + FEATURE_IS_ENABLED_MASK(FEATURE_ISA_BIT) \ ) #define FEATURE_SAY_IS_ENABLED \ @@ -47,7 +67,7 @@ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \ CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("say")) \ + FEATURE_IS_ENABLED_MASK(FEATURE_SAY_BIT)) \ ) #define FEATURE_STATE_IS_ENABLED \ @@ -55,7 +75,7 @@ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \ CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("state")) \ + FEATURE_IS_ENABLED_MASK(FEATURE_STATE_BIT)) \ ) #define FEATURE_SWITCH_IS_ENABLED \ @@ -63,14 +83,21 @@ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \ CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("switch")) \ + FEATURE_IS_ENABLED_MASK(FEATURE_SWITCH_BIT)) \ ) #define FEATURE_BITWISE_IS_ENABLED \ ( \ CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_527 \ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("bitwise")) \ + FEATURE_IS_ENABLED_MASK(FEATURE_BITWISE_BIT)) \ + ) + +#define FEATURE_INDIRECT_IS_ENABLED \ + ( \ + CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527 \ + || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ + FEATURE_IS_ENABLED_MASK(FEATURE_INDIRECT_BIT)) \ ) #define FEATURE_EVALBYTES_IS_ENABLED \ @@ -78,13 +105,13 @@ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \ CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("evalbytes")) \ + FEATURE_IS_ENABLED_MASK(FEATURE_EVALBYTES_BIT)) \ ) #define FEATURE_SIGNATURES_IS_ENABLED \ ( \ CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("signatures") \ + FEATURE_IS_ENABLED_MASK(FEATURE_SIGNATURES_BIT) \ ) #define FEATURE___SUB___IS_ENABLED \ @@ -92,13 +119,13 @@ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \ CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("__SUB__")) \ + FEATURE_IS_ENABLED_MASK(FEATURE___SUB___BIT)) \ ) #define FEATURE_REFALIASING_IS_ENABLED \ ( \ CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("refaliasing") \ + FEATURE_IS_ENABLED_MASK(FEATURE_REFALIASING_BIT) \ ) #define FEATURE_POSTDEREF_QQ_IS_ENABLED \ @@ -106,7 +133,7 @@ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_523 && \ CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("postderef_qq")) \ + FEATURE_IS_ENABLED_MASK(FEATURE_POSTDEREF_QQ_BIT)) \ ) #define FEATURE_UNIEVAL_IS_ENABLED \ @@ -114,13 +141,13 @@ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \ CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("unieval")) \ + FEATURE_IS_ENABLED_MASK(FEATURE_UNIEVAL_BIT)) \ ) #define FEATURE_MYREF_IS_ENABLED \ ( \ CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("myref") \ + FEATURE_IS_ENABLED_MASK(FEATURE_MYREF_BIT) \ ) #define FEATURE_UNICODE_IS_ENABLED \ @@ -128,10 +155,23 @@ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_511 && \ CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("unicode")) \ + FEATURE_IS_ENABLED_MASK(FEATURE_UNICODE_BIT)) \ ) +#define SAVEFEATUREBITS() SAVEI32(PL_compiling.cop_features) + +#define CLEARFEATUREBITS() (PL_compiling.cop_features = 0) + +#define STOREFEATUREBITSHH(hh) \ + (hv_stores((hh), "feature/bits", newSVuv(PL_compiling.cop_features))) + +#define FETCHFEATUREBITSHH(hh) \ + STMT_START { \ + SV **fbsv = hv_fetchs((hh), "feature/bits", FALSE); \ + PL_compiling.cop_features = fbsv ? SvUV(*fbsv) : 0; \ + } STMT_END + #endif /* PERL_CORE or PERL_EXT */ #ifdef PERL_IN_OP_C @@ -165,6 +205,136 @@ S_enable_feature_bundle(pTHX_ SV *ver) } #endif /* PERL_IN_OP_C */ +#ifdef PERL_IN_MG_C + +#define magic_sethint_feature(keysv, keypv, keylen, valsv, valbool) \ + S_magic_sethint_feature(aTHX_ (keysv), (keypv), (keylen), (valsv), (valbool)) +PERL_STATIC_INLINE void +S_magic_sethint_feature(pTHX_ SV *keysv, const char *keypv, STRLEN keylen, + SV *valsv, bool valbool) { + if (keysv) + keypv = SvPV_const(keysv, keylen); + + if (memBEGINs(keypv, keylen, "feature_")) { + const char *subf = keypv + (sizeof("feature_")-1); + U32 mask = 0; + switch (*subf) { + case '_': + if (keylen == sizeof("feature___SUB__")-1 + && memcmp(subf+1, "_SUB__", keylen - sizeof("feature_")) == 0) { + mask = FEATURE___SUB___BIT; + break; + } + return; + + case 'b': + if (keylen == sizeof("feature_bitwise")-1 + && memcmp(subf+1, "itwise", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_BITWISE_BIT; + break; + } + return; + + case 'e': + if (keylen == sizeof("feature_evalbytes")-1 + && memcmp(subf+1, "valbytes", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_EVALBYTES_BIT; + break; + } + return; + + case 'f': + if (keylen == sizeof("feature_fc")-1 + && memcmp(subf+1, "c", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_FC_BIT; + break; + } + return; + + case 'i': + if (keylen == sizeof("feature_indirect")-1 + && memcmp(subf+1, "ndirect", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_INDIRECT_BIT; + break; + } + else if (keylen == sizeof("feature_isa")-1 + && memcmp(subf+1, "sa", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_ISA_BIT; + break; + } + return; + + case 'm': + if (keylen == sizeof("feature_myref")-1 + && memcmp(subf+1, "yref", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_MYREF_BIT; + break; + } + return; + + case 'p': + if (keylen == sizeof("feature_postderef_qq")-1 + && memcmp(subf+1, "ostderef_qq", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_POSTDEREF_QQ_BIT; + break; + } + return; + + case 'r': + if (keylen == sizeof("feature_refaliasing")-1 + && memcmp(subf+1, "efaliasing", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_REFALIASING_BIT; + break; + } + return; + + case 's': + if (keylen == sizeof("feature_say")-1 + && memcmp(subf+1, "ay", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_SAY_BIT; + break; + } + else if (keylen == sizeof("feature_signatures")-1 + && memcmp(subf+1, "ignatures", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_SIGNATURES_BIT; + break; + } + else if (keylen == sizeof("feature_state")-1 + && memcmp(subf+1, "tate", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_STATE_BIT; + break; + } + else if (keylen == sizeof("feature_switch")-1 + && memcmp(subf+1, "witch", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_SWITCH_BIT; + break; + } + return; + + case 'u': + if (keylen == sizeof("feature_unicode")-1 + && memcmp(subf+1, "nicode", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_UNICODE_BIT; + break; + } + else if (keylen == sizeof("feature_unieval")-1 + && memcmp(subf+1, "nieval", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_UNIEVAL_BIT; + break; + } + return; + + default: + return; + } + if (valsv ? SvTRUE(valsv) : valbool) + PL_compiling.cop_features |= mask; + else + PL_compiling.cop_features &= ~mask; + } +} +#endif /* PERL_IN_MG_C */ + #endif /* PERL_FEATURE_H_ */ /* ex: set ro: */ |