1 ################################################################################
5 ## $Date: 2005/06/11 09:37:31 +0200 $
7 ################################################################################
9 ## Version 3.x, Copyright (C) 2004-2005, Marcus Holland-Moritz.
10 ## Version 2.x, Copyright (C) 2001, Paul Marquess.
11 ## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
13 ## This program is free software; you can redistribute it and/or
14 ## modify it under the same terms as Perl itself.
16 ################################################################################
22 PERL_GCC_BRACE_GROUPS_FORBIDDEN
40 #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))
42 # define PL_DBsingle DBsingle
43 # define PL_DBsub DBsub
45 # define PL_compiling compiling
46 # define PL_copline copline
47 # define PL_curcop curcop
48 # define PL_curstash curstash
49 # define PL_debstash debstash
50 # define PL_defgv defgv
51 # define PL_diehook diehook
52 # define PL_dirty dirty
53 # define PL_dowarn dowarn
54 # define PL_errgv errgv
55 # define PL_hexdigit hexdigit
56 # define PL_hints hints
58 # define PL_no_modify no_modify
59 # define PL_perl_destruct_level perl_destruct_level
60 # define PL_perldb perldb
61 # define PL_ppaddr ppaddr
62 # define PL_rsfp_filters rsfp_filters
64 # define PL_stack_base stack_base
65 # define PL_stack_sp stack_sp
66 # define PL_stdingv stdingv
67 # define PL_sv_arenaroot sv_arenaroot
68 # define PL_sv_no sv_no
69 # define PL_sv_undef sv_undef
70 # define PL_sv_yes sv_yes
71 # define PL_tainted tainted
72 # define PL_tainting tainting
76 #ifndef PERL_UNUSED_DECL
78 # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
79 # define PERL_UNUSED_DECL
81 # define PERL_UNUSED_DECL __attribute__((unused))
84 # define PERL_UNUSED_DECL
88 __UNDEFINED__ NOOP (void)0
89 __UNDEFINED__ dNOOP extern int Perl___notused PERL_UNUSED_DECL
92 # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
93 # define NVTYPE long double
95 # define NVTYPE double
102 # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
104 # define INT2PTR(any,d) (any)(d)
106 # if PTRSIZE == LONGSIZE
107 # define PTRV unsigned long
109 # define PTRV unsigned
111 # define INT2PTR(any,d) (any)(PTRV)(d)
114 # define NUM2PTR(any,d) (any)(PTRV)(d)
115 # define PTR2IV(p) INT2PTR(IV,p)
116 # define PTR2UV(p) INT2PTR(UV,p)
117 # define PTR2NV(p) NUM2PTR(NV,p)
119 # if PTRSIZE == LONGSIZE
120 # define PTR2ul(p) (unsigned long)(p)
122 # define PTR2ul(p) INT2PTR(unsigned long,p)
125 #endif /* !INT2PTR */
127 #undef START_EXTERN_C
131 # define START_EXTERN_C extern "C" {
132 # define END_EXTERN_C }
133 # define EXTERN_C extern "C"
135 # define START_EXTERN_C
136 # define END_EXTERN_C
137 # define EXTERN_C extern
140 #ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN
141 # if defined(__STRICT_ANSI__) && defined(PERL_GCC_PEDANTIC)
142 # define PERL_GCC_BRACE_GROUPS_FORBIDDEN
148 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus)
149 # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
152 # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__)
153 # define STMT_START if (1)
154 # define STMT_END else (void)0
156 # define STMT_START do
157 # define STMT_END while (0)
161 __UNDEFINED__ boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
163 /* DEFSV appears first in 5.004_56 */
164 __UNDEFINED__ DEFSV GvSV(PL_defgv)
165 __UNDEFINED__ SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
167 /* Older perls (<=5.003) lack AvFILLp */
168 __UNDEFINED__ AvFILLp AvFILL
170 __UNDEFINED__ ERRSV get_sv("@",FALSE)
172 __UNDEFINED__ newSVpvn(data,len) ((data) \
173 ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \
177 * This function's backport doesn't support the length parameter, but
178 * rather ignores it. Portability can only be ensured if the length
179 * parameter is used for speed reasons, but the length can always be
180 * correctly computed from the string argument.
183 __UNDEFINED__ gv_stashpvn(str,len,create) gv_stashpv(str,create)
186 __UNDEFINED__ get_cv perl_get_cv
187 __UNDEFINED__ get_sv perl_get_sv
188 __UNDEFINED__ get_av perl_get_av
189 __UNDEFINED__ get_hv perl_get_hv
193 __UNDEFINED__ memNE(s1,s2,l) (memcmp(s1,s2,l))
194 __UNDEFINED__ memEQ(s1,s2,l) (!memcmp(s1,s2,l))
196 __UNDEFINED__ memNE(s1,s2,l) (bcmp(s1,s2,l))
197 __UNDEFINED__ memEQ(s1,s2,l) (!bcmp(s1,s2,l))
200 __UNDEFINED__ MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t))
201 __UNDEFINED__ CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
203 __UNDEFINED__ ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t))
205 __UNDEFINED__ ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)),d)
208 __UNDEFINED__ Poison(d,n,t) (void)memset((char*)(d), 0xAB, (n) * sizeof(t))
210 __UNDEFINED__ dUNDERBAR dNOOP
211 __UNDEFINED__ UNDERBAR DEFSV
213 __UNDEFINED__ dAX I32 ax = MARK - PL_stack_base + 1
214 __UNDEFINED__ dITEMS I32 items = SP - MARK
216 __UNDEFINED__ dXSTARG SV * targ = sv_newmortal()
220 XS(XS_Devel__PPPort_dXSTARG); /* prototype */
221 XS(XS_Devel__PPPort_dXSTARG)
227 iv = SvIV(ST(0)) + 1;
234 newXS("Devel::PPPort::dXSTARG", XS_Devel__PPPort_dXSTARG, file);
239 gv_stashpvn(name, create)
243 RETVAL = gv_stashpvn(name, strlen(name), create) != NULL;
252 RETVAL = get_sv(name, create) != NULL;
261 RETVAL = get_av(name, create) != NULL;
270 RETVAL = get_hv(name, create) != NULL;
279 RETVAL = get_cv(name, create) != NULL;
286 XPUSHs(newSVpvn("test", 4));
287 XPUSHs(newSVpvn("test", 2));
288 XPUSHs(newSVpvn("test", 0));
289 XPUSHs(newSVpvn(NULL, 2));
290 XPUSHs(newSVpvn(NULL, 0));
296 RETVAL = newSVsv(&PL_sv_undef);
303 RETVAL = newSVsv(&PL_sv_yes);
310 RETVAL = newSVsv(&PL_sv_no);
318 PL_na = strlen(string);
327 RETVAL = newSVsv(boolSV(value));
334 RETVAL = newSVsv(DEFSV);
341 RETVAL = SvTRUE(ERRSV);
350 RETVAL = newSVsv(UNDERBAR);
357 use vars qw($my_sv @my_av %my_hv);
359 my @s = &Devel::PPPort::newSVpvn();
367 ok(!defined(&Devel::PPPort::PL_sv_undef()));
368 ok(&Devel::PPPort::PL_sv_yes());
369 ok(!&Devel::PPPort::PL_sv_no());
370 ok(&Devel::PPPort::PL_na("abcd"), 4);
372 ok(&Devel::PPPort::boolSV(1));
373 ok(!&Devel::PPPort::boolSV(0));
376 ok(&Devel::PPPort::DEFSV(), "Fred");
377 ok(&Devel::PPPort::UNDERBAR(), "Fred");
380 ok(!&Devel::PPPort::ERRSV());
381 eval { cannot_call_this_one() };
382 ok(&Devel::PPPort::ERRSV());
384 ok(&Devel::PPPort::gv_stashpvn('Devel::PPPort', 0));
385 ok(!&Devel::PPPort::gv_stashpvn('does::not::exist', 0));
386 ok(&Devel::PPPort::gv_stashpvn('does::not::exist', 1));
389 ok(&Devel::PPPort::get_sv('my_sv', 0));
390 ok(!&Devel::PPPort::get_sv('not_my_sv', 0));
391 ok(&Devel::PPPort::get_sv('not_my_sv', 1));
394 ok(&Devel::PPPort::get_av('my_av', 0));
395 ok(!&Devel::PPPort::get_av('not_my_av', 0));
396 ok(&Devel::PPPort::get_av('not_my_av', 1));
399 ok(&Devel::PPPort::get_hv('my_hv', 0));
400 ok(!&Devel::PPPort::get_hv('not_my_hv', 0));
401 ok(&Devel::PPPort::get_hv('not_my_hv', 1));
404 ok(&Devel::PPPort::get_cv('my_cv', 0));
405 ok(!&Devel::PPPort::get_cv('not_my_cv', 0));
406 ok(&Devel::PPPort::get_cv('not_my_cv', 1));
408 ok(Devel::PPPort::dXSTARG(42), 43);