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