This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update rmg concerning feature bundles
[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
2b9e0ab7 16#define FEATURE_BUNDLE_CUSTOM (HINT_FEATURE_MASK >> HINT_FEATURE_SHIFT)
f2c01b15 17
d1fd0100
FC
18#define CURRENT_HINTS \
19 (PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints)
20#define CURRENT_FEATURE_BUNDLE (CURRENT_HINTS >> HINT_FEATURE_SHIFT)
21
7d058bc9 22#define FEATURE_IS_ENABLED(name) \
ef744b29 23 ((CURRENT_HINTS \
7d058bc9
FC
24 & HINT_LOCALIZE_HH) \
25 && Perl_feature_is_enabled(aTHX_ STR_WITH_LEN(name)))
26/* The longest string we pass in. */
1b6e8741 27#define MAX_FEATURE_LEN (sizeof("evalbytes")-1)
7d058bc9 28
03222170
FC
29#define FEATURE_SAY_IS_ENABLED \
30 ( \
31 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
32 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
33 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
34 FEATURE_IS_ENABLED("say")) \
35 )
36
37#define FEATURE_STATE_IS_ENABLED \
38 ( \
39 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
40 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
41 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
42 FEATURE_IS_ENABLED("state")) \
43 )
44
45#define FEATURE_SWITCH_IS_ENABLED \
46 ( \
47 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
48 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
49 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
50 FEATURE_IS_ENABLED("switch")) \
51 )
52
53#define FEATURE_EVALBYTES_IS_ENABLED \
54 ( \
55 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
56 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
57 FEATURE_IS_ENABLED("evalbytes")) \
58 )
59
60#define FEATURE_ARYBASE_IS_ENABLED \
61 ( \
beda0318 62 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_511 \
03222170 63 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
3fff3427 64 FEATURE_IS_ENABLED("arybase")) \
03222170
FC
65 )
66
67#define FEATURE___SUB___IS_ENABLED \
68 ( \
69 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
70 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
71 FEATURE_IS_ENABLED("__SUB__")) \
72 )
73
74#define FEATURE_UNIEVAL_IS_ENABLED \
75 ( \
76 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \
77 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
78 FEATURE_IS_ENABLED("unieval")) \
79 )
80
81#define FEATURE_UNICODE_IS_ENABLED \
82 ( \
83 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_511 && \
84 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_515) \
85 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
86 FEATURE_IS_ENABLED("unicode")) \
87 )
88
89
f2c01b15
FC
90#endif /* PERL_CORE or PERL_EXT */
91
4160ddbd
FC
92#ifdef PERL_IN_OP_C
93PERL_STATIC_INLINE void
94S_enable_feature_bundle(pTHX_ SV *ver)
95{
96 SV *comp_ver = sv_newmortal();
97 PL_hints = (PL_hints &~ HINT_FEATURE_MASK)
98 | (
99 (sv_setnv(comp_ver, 5.015),
100 vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
101 ? FEATURE_BUNDLE_515 :
102 (sv_setnv(comp_ver, 5.011),
103 vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
104 ? FEATURE_BUNDLE_511 :
105 (sv_setnv(comp_ver, 5.009005),
106 vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
107 ? FEATURE_BUNDLE_510 :
108 FEATURE_BUNDLE_DEFAULT
109 ) << HINT_FEATURE_SHIFT;
110}
111#endif /* PERL_IN_OP_C */
112
f2c01b15 113/* ex: set ro: */