This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] Optimize split //
[perl5.git] / ext / Devel / PPPort / parts / inc / variables
CommitLineData
0d0f8426
MHM
1################################################################################
2##
a89b7ab8 3## $Revision: 8 $
0d0f8426 4## $Author: mhx $
a89b7ab8 5## $Date: 2007/03/23 16:24:34 +0100 $
0d0f8426
MHM
6##
7################################################################################
8##
d2dacc4f 9## Version 3.x, Copyright (C) 2004-2007, Marcus Holland-Moritz.
0d0f8426
MHM
10## Version 2.x, Copyright (C) 2001, Paul Marquess.
11## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
12##
13## This program is free software; you can redistribute it and/or
14## modify it under the same terms as Perl itself.
15##
16################################################################################
17
18=provides
19
cac25305 20/PL_\w+/
0d0f8426
MHM
21PERL_SIGNALS_UNSAFE_FLAG
22
cac25305
MHM
23=dontwarn
24
25D_PPP_PERL_SIGNALS_INIT
26
0d0f8426
MHM
27=implementation
28
29#ifndef PERL_SIGNALS_UNSAFE_FLAG
30
31#define PERL_SIGNALS_UNSAFE_FLAG 0x0001
32
cac25305
MHM
33#if { VERSION < 5.8.0 }
34# define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG
35#else
36# define D_PPP_PERL_SIGNALS_INIT 0
37#endif
38
39__NEED_VAR__ U32 PL_signals = D_PPP_PERL_SIGNALS_INIT;
40
41#endif
0d0f8426 42
cac25305
MHM
43/* Hint: PL_ppaddr
44 * Calling an op via PL_ppaddr requires passing a context argument
45 * for threaded builds. Since the context argument is different for
46 * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will
47 * automatically be defined as the correct argument.
48 */
49
50#if { VERSION <= 5.005_04 }
51/* Replace: 1 */
52# define PL_ppaddr ppaddr
53# define PL_no_modify no_modify
54/* Replace: 0 */
55#endif
56
57#if { VERSION <= 5.004_05 }
58/* Replace: 1 */
59# define PL_DBsignal DBsignal
60# define PL_DBsingle DBsingle
61# define PL_DBsub DBsub
62# define PL_DBtrace DBtrace
63# define PL_Sv Sv
64# define PL_compiling compiling
65# define PL_copline copline
66# define PL_curcop curcop
67# define PL_curstash curstash
68# define PL_debstash debstash
69# define PL_defgv defgv
70# define PL_diehook diehook
71# define PL_dirty dirty
72# define PL_dowarn dowarn
73# define PL_errgv errgv
a89b7ab8 74# define PL_expect expect
cac25305
MHM
75# define PL_hexdigit hexdigit
76# define PL_hints hints
77# define PL_laststatval laststatval
78# define PL_na na
79# define PL_perl_destruct_level perl_destruct_level
80# define PL_perldb perldb
81# define PL_rsfp_filters rsfp_filters
82# define PL_rsfp rsfp
83# define PL_stack_base stack_base
84# define PL_stack_sp stack_sp
85# define PL_statcache statcache
86# define PL_stdingv stdingv
87# define PL_sv_arenaroot sv_arenaroot
88# define PL_sv_no sv_no
89# define PL_sv_undef sv_undef
90# define PL_sv_yes sv_yes
91# define PL_tainted tainted
92# define PL_tainting tainting
93/* Replace: 0 */
0d0f8426
MHM
94#endif
95
53a7735b
DM
96#if { VERSION >= 5.9.5 }
97# define PL_PARSER_EXISTS
98# define PL_expect (PL_parser ? PL_parser->expect : 0)
99# define PL_copline (PL_parser ? PL_parser->copline : 0)
2f9285f8 100# define PL_rsfp (PL_parser ? PL_parser->rsfp : 0)
5486870f 101# define PL_rsfp_filters (PL_parser ? PL_parser->rsfp_filters : 0)
53a7735b
DM
102#endif
103
0d0f8426
MHM
104=xsinit
105
106#define NEED_PL_signals
107
108=xsmisc
109
110U32 get_PL_signals_1(void)
111{
112 return PL_signals;
113}
114
115extern U32 get_PL_signals_2(void);
116extern U32 get_PL_signals_3(void);
117
cac25305
MHM
118#define ppp_TESTVAR(var) STMT_START { XPUSHs(newSViv(&var != NULL)); count++; } STMT_END
119
0d0f8426
MHM
120=xsubs
121
122int
123compare_PL_signals()
124 CODE:
125 {
126 U32 ref = get_PL_signals_1();
127 RETVAL = ref == get_PL_signals_2() && ref == get_PL_signals_3();
128 }
129 OUTPUT:
130 RETVAL
131
cac25305
MHM
132SV *
133PL_sv_undef()
134 CODE:
135 RETVAL = newSVsv(&PL_sv_undef);
136 OUTPUT:
137 RETVAL
138
139SV *
140PL_sv_yes()
141 CODE:
142 RETVAL = newSVsv(&PL_sv_yes);
143 OUTPUT:
144 RETVAL
145
146SV *
147PL_sv_no()
148 CODE:
149 RETVAL = newSVsv(&PL_sv_no);
150 OUTPUT:
151 RETVAL
152
153int
154PL_na(string)
155 char *string
156 CODE:
157 PL_na = strlen(string);
158 RETVAL = PL_na;
159 OUTPUT:
160 RETVAL
161
162SV *
163PL_Sv()
164 CODE:
165 PL_Sv = newSVpv("mhx", 0);
166 RETVAL = PL_Sv;
167 OUTPUT:
168 RETVAL
169
170SV *
171PL_copline()
172 CODE:
173 RETVAL = newSViv((IV) PL_copline);
174 OUTPUT:
175 RETVAL
176
177SV *
178PL_hexdigit()
179 CODE:
180 RETVAL = newSVpv(PL_hexdigit, 0);
181 OUTPUT:
182 RETVAL
183
184SV *
185PL_hints()
186 CODE:
187 RETVAL = newSViv((IV) PL_hints);
188 OUTPUT:
189 RETVAL
190
191void
192PL_ppaddr(string)
193 char *string
194 PPCODE:
195 PUSHMARK(SP);
196 XPUSHs(sv_2mortal(newSVpv(string, 0)));
197 PUTBACK;
198 ENTER;
199 (void)*(PL_ppaddr[OP_UC])(aTHXR);
200 SPAGAIN;
201 LEAVE;
202 XSRETURN(1);
203
204void
205other_variables()
206 PREINIT:
207 int count = 0;
208 PPCODE:
209 ppp_TESTVAR(PL_DBsignal);
210 ppp_TESTVAR(PL_DBsingle);
211 ppp_TESTVAR(PL_DBsub);
212 ppp_TESTVAR(PL_DBtrace);
213 ppp_TESTVAR(PL_compiling);
214 ppp_TESTVAR(PL_curcop);
215 ppp_TESTVAR(PL_curstash);
216 ppp_TESTVAR(PL_debstash);
217 ppp_TESTVAR(PL_defgv);
218 ppp_TESTVAR(PL_diehook);
219 ppp_TESTVAR(PL_dirty);
220 ppp_TESTVAR(PL_dowarn);
221 ppp_TESTVAR(PL_errgv);
53a7735b
DM
222#ifdef PL_PARSER_EXISTS
223 ppp_TESTVAR(PL_parser); /* just any var that isn't PL_expect */
224#else
a89b7ab8 225 ppp_TESTVAR(PL_expect);
53a7735b 226#endif
cac25305
MHM
227 ppp_TESTVAR(PL_laststatval);
228 ppp_TESTVAR(PL_no_modify);
229 ppp_TESTVAR(PL_perl_destruct_level);
230 ppp_TESTVAR(PL_perldb);
2f9285f8
DM
231#ifdef PL_PARSER_EXISTS
232 ppp_TESTVAR(PL_parser); /* just any var that isn't PL_expect */
5486870f 233 ppp_TESTVAR(PL_parser);
2f9285f8 234#else
cac25305 235 ppp_TESTVAR(PL_rsfp);
5486870f 236 ppp_TESTVAR(PL_rsfp_filters);
2f9285f8 237#endif
cac25305
MHM
238 ppp_TESTVAR(PL_stack_base);
239 ppp_TESTVAR(PL_stack_sp);
240 ppp_TESTVAR(PL_statcache);
241 ppp_TESTVAR(PL_stdingv);
242 ppp_TESTVAR(PL_sv_arenaroot);
243 ppp_TESTVAR(PL_tainted);
244 ppp_TESTVAR(PL_tainting);
245 XSRETURN(count);
246
a89b7ab8 247=tests plan => 37
0d0f8426
MHM
248
249ok(Devel::PPPort::compare_PL_signals());
250
cac25305
MHM
251ok(!defined(&Devel::PPPort::PL_sv_undef()));
252ok(&Devel::PPPort::PL_sv_yes());
253ok(!&Devel::PPPort::PL_sv_no());
254ok(&Devel::PPPort::PL_na("abcd"), 4);
255ok(&Devel::PPPort::PL_Sv(), "mhx");
256ok(defined &Devel::PPPort::PL_copline());
257ok(&Devel::PPPort::PL_hexdigit() =~ /^[0-9a-zA-Z]+$/);
258ok(defined &Devel::PPPort::PL_hints());
259ok(&Devel::PPPort::PL_ppaddr("mhx"), "MHX");
260
261for (&Devel::PPPort::other_variables()) {
262 ok($_ != 0);
263}