This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
stop %^H pointing to being-freed hash; #112326
[perl5.git] / feature.h
CommitLineData
f2c01b15
FC
1/* -*- buffer-read-only: t -*-
2 !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
3 This file is built by regen/feature.pl.
4 Any changes made here will be lost!
5 */
6
7
8#if defined(PERL_CORE) || defined (PERL_EXT)
9
10#define HINT_FEATURE_SHIFT 26
11
12#define FEATURE_BUNDLE_DEFAULT 0
13#define FEATURE_BUNDLE_510 1
14#define FEATURE_BUNDLE_511 2
15#define FEATURE_BUNDLE_515 3
2b9e0ab7 16#define FEATURE_BUNDLE_CUSTOM (HINT_FEATURE_MASK >> HINT_FEATURE_SHIFT)
f2c01b15 17
d1fd0100
FC
18#define CURRENT_HINTS \
19 (PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints)
035b6821
FC
20#define CURRENT_FEATURE_BUNDLE \
21 ((CURRENT_HINTS & HINT_FEATURE_MASK) >> HINT_FEATURE_SHIFT)
d1fd0100 22
7d058bc9 23#define FEATURE_IS_ENABLED(name) \
ef744b29 24 ((CURRENT_HINTS \
7d058bc9
FC
25 & HINT_LOCALIZE_HH) \
26 && Perl_feature_is_enabled(aTHX_ STR_WITH_LEN(name)))
27/* The longest string we pass in. */
1b6e8741 28#define MAX_FEATURE_LEN (sizeof("evalbytes")-1)
7d058bc9 29
2a4315f8
BF
30#define FEATURE_FC_IS_ENABLED \
31 ( \
32 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
33 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
34 FEATURE_IS_ENABLED("fc")) \
35 )
36
03222170
FC
37#define FEATURE_SAY_IS_ENABLED \
38 ( \
39 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
40 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
41 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
42 FEATURE_IS_ENABLED("say")) \
43 )
44
45#define FEATURE_STATE_IS_ENABLED \
46 ( \
47 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
48 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
49 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
50 FEATURE_IS_ENABLED("state")) \
51 )
52
53#define FEATURE_SWITCH_IS_ENABLED \
54 ( \
55 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
56 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
57 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
58 FEATURE_IS_ENABLED("switch")) \
59 )
60
61#define FEATURE_EVALBYTES_IS_ENABLED \
62 ( \
63 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
64 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
65 FEATURE_IS_ENABLED("evalbytes")) \
66 )
67
68#define FEATURE_ARYBASE_IS_ENABLED \
69 ( \
beda0318 70 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_511 \
03222170 71 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
3fff3427 72 FEATURE_IS_ENABLED("arybase")) \
03222170
FC
73 )
74
75#define FEATURE___SUB___IS_ENABLED \
76 ( \
77 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
78 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
79 FEATURE_IS_ENABLED("__SUB__")) \
80 )
81
82#define FEATURE_UNIEVAL_IS_ENABLED \
83 ( \
84 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
85 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
86 FEATURE_IS_ENABLED("unieval")) \
87 )
88
89#define FEATURE_UNICODE_IS_ENABLED \
90 ( \
91 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_511 && \
92 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
93 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
94 FEATURE_IS_ENABLED("unicode")) \
95 )
96
97
f2c01b15
FC
98#endif /* PERL_CORE or PERL_EXT */
99
4160ddbd
FC
100#ifdef PERL_IN_OP_C
101PERL_STATIC_INLINE void
102S_enable_feature_bundle(pTHX_ SV *ver)
103{
104 SV *comp_ver = sv_newmortal();
105 PL_hints = (PL_hints &~ HINT_FEATURE_MASK)
106 | (
107 (sv_setnv(comp_ver, 5.015),
108 vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
109 ? FEATURE_BUNDLE_515 :
110 (sv_setnv(comp_ver, 5.011),
111 vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
112 ? FEATURE_BUNDLE_511 :
113 (sv_setnv(comp_ver, 5.009005),
114 vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
115 ? FEATURE_BUNDLE_510 :
116 FEATURE_BUNDLE_DEFAULT
117 ) << HINT_FEATURE_SHIFT;
6389c777
FC
118 /* special case */
119 assert(PL_curcop == &PL_compiling);
120 if (FEATURE_UNICODE_IS_ENABLED) PL_hints |= HINT_UNI_8_BIT;
121 else PL_hints &= ~HINT_UNI_8_BIT;
4160ddbd
FC
122}
123#endif /* PERL_IN_OP_C */
124
f2c01b15 125/* ex: set ro: */