This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Porting/bisect-runner.pl: Wrap pod lines to 79 cols
[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
fc4b5f72
NC
23/* Avoid using ... && Perl_feature_is_enabled(...) as that triggers a bug in
24 the HP-UX cc on PA-RISC */
7d058bc9 25#define FEATURE_IS_ENABLED(name) \
ef744b29 26 ((CURRENT_HINTS \
7d058bc9 27 & HINT_LOCALIZE_HH) \
fc4b5f72 28 ? Perl_feature_is_enabled(aTHX_ STR_WITH_LEN(name)) : FALSE)
7d058bc9 29/* The longest string we pass in. */
158becca 30#define MAX_FEATURE_LEN (sizeof("postderef_qq")-1)
7d058bc9 31
2a4315f8
BF
32#define FEATURE_FC_IS_ENABLED \
33 ( \
34 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
35 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
36 FEATURE_IS_ENABLED("fc")) \
37 )
38
03222170
FC
39#define FEATURE_SAY_IS_ENABLED \
40 ( \
41 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
42 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
43 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
44 FEATURE_IS_ENABLED("say")) \
45 )
46
47#define FEATURE_STATE_IS_ENABLED \
48 ( \
49 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
50 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
51 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
52 FEATURE_IS_ENABLED("state")) \
53 )
54
55#define FEATURE_SWITCH_IS_ENABLED \
56 ( \
57 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
58 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
59 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
60 FEATURE_IS_ENABLED("switch")) \
61 )
62
cec892e7
FC
63#define FEATURE_BITWISE_IS_ENABLED \
64 ( \
65 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
66 FEATURE_IS_ENABLED("bitwise") \
67 )
68
03222170
FC
69#define FEATURE_EVALBYTES_IS_ENABLED \
70 ( \
71 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
72 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
73 FEATURE_IS_ENABLED("evalbytes")) \
74 )
75
b9a36c95
FC
76#define FEATURE_POSTDEREF_IS_ENABLED \
77 ( \
78 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
79 FEATURE_IS_ENABLED("postderef") \
80 )
81
03222170
FC
82#define FEATURE_ARYBASE_IS_ENABLED \
83 ( \
beda0318 84 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_511 \
03222170 85 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
3fff3427 86 FEATURE_IS_ENABLED("arybase")) \
03222170
FC
87 )
88
30d9c59b
Z
89#define FEATURE_SIGNATURES_IS_ENABLED \
90 ( \
91 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
92 FEATURE_IS_ENABLED("signatures") \
93 )
94
03222170
FC
95#define FEATURE___SUB___IS_ENABLED \
96 ( \
97 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
98 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
99 FEATURE_IS_ENABLED("__SUB__")) \
100 )
101
baabe3fb 102#define FEATURE_REFALIASING_IS_ENABLED \
7b1dc818
FC
103 ( \
104 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
baabe3fb 105 FEATURE_IS_ENABLED("refaliasing") \
7b1dc818
FC
106 )
107
ebd25686
FC
108#define FEATURE_LEXSUBS_IS_ENABLED \
109 ( \
110 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
111 FEATURE_IS_ENABLED("lexsubs") \
112 )
113
158becca
FC
114#define FEATURE_POSTDEREF_QQ_IS_ENABLED \
115 ( \
116 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
117 FEATURE_IS_ENABLED("postderef_qq") \
118 )
119
03222170
FC
120#define FEATURE_UNIEVAL_IS_ENABLED \
121 ( \
122 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
123 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
124 FEATURE_IS_ENABLED("unieval")) \
125 )
126
127#define FEATURE_UNICODE_IS_ENABLED \
128 ( \
129 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_511 && \
130 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
131 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
132 FEATURE_IS_ENABLED("unicode")) \
133 )
134
135
f2c01b15
FC
136#endif /* PERL_CORE or PERL_EXT */
137
4160ddbd
FC
138#ifdef PERL_IN_OP_C
139PERL_STATIC_INLINE void
140S_enable_feature_bundle(pTHX_ SV *ver)
141{
142 SV *comp_ver = sv_newmortal();
143 PL_hints = (PL_hints &~ HINT_FEATURE_MASK)
144 | (
145 (sv_setnv(comp_ver, 5.015),
146 vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
147 ? FEATURE_BUNDLE_515 :
148 (sv_setnv(comp_ver, 5.011),
149 vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
150 ? FEATURE_BUNDLE_511 :
151 (sv_setnv(comp_ver, 5.009005),
152 vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
153 ? FEATURE_BUNDLE_510 :
154 FEATURE_BUNDLE_DEFAULT
155 ) << HINT_FEATURE_SHIFT;
6389c777
FC
156 /* special case */
157 assert(PL_curcop == &PL_compiling);
158 if (FEATURE_UNICODE_IS_ENABLED) PL_hints |= HINT_UNI_8_BIT;
159 else PL_hints &= ~HINT_UNI_8_BIT;
4160ddbd
FC
160}
161#endif /* PERL_IN_OP_C */
162
f2c01b15 163/* ex: set ro: */