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