sv_utf8_(downgrade|decode) no longer marked experimental
[perl.git] / feature.h
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 #ifndef PERL_FEATURE_H_
9 #define PERL_FEATURE_H_
10
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
19 #define FEATURE_BUNDLE_523      4
20 #define FEATURE_BUNDLE_527      5
21 #define FEATURE_BUNDLE_CUSTOM   (HINT_FEATURE_MASK >> HINT_FEATURE_SHIFT)
22
23 #define CURRENT_HINTS \
24     (PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints)
25 #define CURRENT_FEATURE_BUNDLE \
26     ((CURRENT_HINTS & HINT_FEATURE_MASK) >> HINT_FEATURE_SHIFT)
27
28 /* Avoid using ... && Perl_feature_is_enabled(...) as that triggers a bug in
29    the HP-UX cc on PA-RISC */
30 #define FEATURE_IS_ENABLED(name)                                        \
31         ((CURRENT_HINTS                                                  \
32            & HINT_LOCALIZE_HH)                                            \
33             ? Perl_feature_is_enabled(aTHX_ STR_WITH_LEN(name)) : FALSE)
34 /* The longest string we pass in.  */
35 #define MAX_FEATURE_LEN (sizeof("postderef_qq")-1)
36
37 #define FEATURE_FC_IS_ENABLED \
38     ( \
39         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
40          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
41      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
42          FEATURE_IS_ENABLED("fc")) \
43     )
44
45 #define FEATURE_SAY_IS_ENABLED \
46     ( \
47         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
48          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
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 && \
56          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
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 && \
64          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
65      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
66          FEATURE_IS_ENABLED("switch")) \
67     )
68
69 #define FEATURE_BITWISE_IS_ENABLED \
70     ( \
71         CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_527 \
72      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
73          FEATURE_IS_ENABLED("bitwise")) \
74     )
75
76 #define FEATURE_EVALBYTES_IS_ENABLED \
77     ( \
78         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
79          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
80      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
81          FEATURE_IS_ENABLED("evalbytes")) \
82     )
83
84 #define FEATURE_SIGNATURES_IS_ENABLED \
85     ( \
86         CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
87          FEATURE_IS_ENABLED("signatures") \
88     )
89
90 #define FEATURE___SUB___IS_ENABLED \
91     ( \
92         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
93          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
94      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
95          FEATURE_IS_ENABLED("__SUB__")) \
96     )
97
98 #define FEATURE_REFALIASING_IS_ENABLED \
99     ( \
100         CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
101          FEATURE_IS_ENABLED("refaliasing") \
102     )
103
104 #define FEATURE_POSTDEREF_QQ_IS_ENABLED \
105     ( \
106         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_523 && \
107          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
108      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
109          FEATURE_IS_ENABLED("postderef_qq")) \
110     )
111
112 #define FEATURE_UNIEVAL_IS_ENABLED \
113     ( \
114         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
115          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
116      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
117          FEATURE_IS_ENABLED("unieval")) \
118     )
119
120 #define FEATURE_MYREF_IS_ENABLED \
121     ( \
122         CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
123          FEATURE_IS_ENABLED("myref") \
124     )
125
126 #define FEATURE_UNICODE_IS_ENABLED \
127     ( \
128         (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_511 && \
129          CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
130      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
131          FEATURE_IS_ENABLED("unicode")) \
132     )
133
134
135 #endif /* PERL_CORE or PERL_EXT */
136
137 #ifdef PERL_IN_OP_C
138 PERL_STATIC_INLINE void
139 S_enable_feature_bundle(pTHX_ SV *ver)
140 {
141     SV *comp_ver = sv_newmortal();
142     PL_hints = (PL_hints &~ HINT_FEATURE_MASK)
143              | (
144                   (sv_setnv(comp_ver, 5.027),
145                    vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
146                         ? FEATURE_BUNDLE_527 :
147                   (sv_setnv(comp_ver, 5.023),
148                    vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
149                         ? FEATURE_BUNDLE_523 :
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;
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;
165 }
166 #endif /* PERL_IN_OP_C */
167
168 #endif /* PERL_FEATURE_H_ */
169
170 /* ex: set ro: */