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