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