diff options
author | David Mitchell <davem@iabyn.com> | 2015-04-17 20:38:49 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2015-04-19 18:42:00 +0100 |
commit | 1fafe688be3ff13b81d5e18b2a8766dd719ee8eb (patch) | |
tree | 20f30acb1bdcf2fb7761b3d570ac7c18630b6e5c | |
parent | e7c18dde420590ee76509d2187610a43444ad069 (diff) | |
download | perl-1fafe688be3ff13b81d5e18b2a8766dd719ee8eb.tar.gz |
op_parent(): only exist under -DPERL_OP_PARENT
Make the function Perl_op_parent() only be present in perls built with
-DPERL_OP_PARENT. Previously the function was present in all builds, but
always returned NULL on non PERL_OP_PARENT builds.
-rw-r--r-- | embed.fnc | 2 | ||||
-rw-r--r-- | embed.h | 4 | ||||
-rw-r--r-- | ext/B/B.xs | 4 | ||||
-rw-r--r-- | ext/B/t/b.t | 2 | ||||
-rw-r--r-- | makedef.pl | 7 | ||||
-rw-r--r-- | op.c | 14 | ||||
-rw-r--r-- | proto.h | 12 |
7 files changed, 30 insertions, 15 deletions
@@ -783,7 +783,9 @@ Ap |void |op_refcnt_lock Ap |void |op_refcnt_unlock Apdn |OP* |op_sibling_splice|NULLOK OP *parent|NULLOK OP *start \ |int del_count|NULLOK OP* insert +#ifdef PERL_OP_PARENT Apdn |OP* |op_parent|NN OP *o +#endif #if defined(PERL_IN_OP_C) s |OP* |listkids |NULLOK OP* o #endif @@ -433,7 +433,6 @@ #define op_free(a) Perl_op_free(aTHX_ a) #define op_linklist(a) Perl_op_linklist(aTHX_ a) #define op_null(a) Perl_op_null(aTHX_ a) -#define op_parent Perl_op_parent #define op_prepend_elem(a,b,c) Perl_op_prepend_elem(aTHX_ a,b,c) #define op_refcnt_lock() Perl_op_refcnt_lock(aTHX) #define op_refcnt_unlock() Perl_op_refcnt_unlock(aTHX) @@ -825,6 +824,9 @@ #if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C) #define _get_regclass_nonbitmap_data(a,b,c,d,e,f) Perl__get_regclass_nonbitmap_data(aTHX_ a,b,c,d,e,f) #endif +#if defined(PERL_OP_PARENT) +#define op_parent Perl_op_parent +#endif #if defined(UNLINK_ALL_VERSIONS) #define unlnk(a) Perl_unlnk(aTHX_ a) #endif diff --git a/ext/B/B.xs b/ext/B/B.xs index e8698c5ae3..016e0309ff 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -1260,7 +1260,11 @@ next(o) PTR2IV(CopHINTHASH_get(cCOPo))); break; case 52: /* B::OP::parent */ +#ifdef PERL_OP_PARENT ret = make_op_object(aTHX_ op_parent(o)); +#else + ret = make_op_object(aTHX_ NULL); +#endif break; case 53: /* B::METHOP::first */ /* METHOP struct has an op_first/op_meth_sv union diff --git a/ext/B/t/b.t b/ext/B/t/b.t index c382b421c9..1420f91fcf 100644 --- a/ext/B/t/b.t +++ b/ext/B/t/b.t @@ -474,7 +474,7 @@ EOS # test op_parent SKIP: { - unless ($Config::Config{ccflags} =~ /PERL_OP_PARENT/) { + unless ($B::OP::does_parent) { skip "op_parent only present with -DPERL_OP_PARENT builds", 6; } my $lineseq = B::svref_2object(sub{my $x = 1})->ROOT->first; diff --git a/makedef.pl b/makedef.pl index b31d8a0aa1..8a570830e2 100644 --- a/makedef.pl +++ b/makedef.pl @@ -421,6 +421,13 @@ unless ($define{'PERL_IMPLICIT_CONTEXT'}) { Perl_my_cxt_index ); } + +unless ($define{'PERL_OP_PARENT'}) { + ++$skip{$_} foreach qw( + Perl_op_parent + ); +} + if ($define{'NO_MATHOMS'}) { # win32 builds happen in the win32/ subdirectory, but vms builds happen # at the top level, so we need to look in two candidate locations for @@ -1351,12 +1351,13 @@ Perl_op_sibling_splice(OP *parent, OP *start, int del_count, OP* insert) } +#ifdef PERL_OP_PARENT + /* =for apidoc op_parent -returns the parent OP of o, if it has a parent. Returns NULL otherwise. -(Currently perl must be built with C<-DPERL_OP_PARENT> for this feature to -work. +Returns the parent OP of o, if it has a parent. Returns NULL otherwise. +This function is only available on perls built with C<-DPERL_OP_PARENT>. =cut */ @@ -1365,16 +1366,13 @@ OP * Perl_op_parent(OP *o) { PERL_ARGS_ASSERT_OP_PARENT; -#ifdef PERL_OP_PARENT while (OpHAS_SIBLING(o)) o = OpSIBLING(o); return o->op_sibparent; -#else - PERL_UNUSED_ARG(o); - return NULL; -#endif } +#endif + /* replace the sibling following start with a new UNOP, which becomes * the parent of the original sibling; e.g. @@ -3270,11 +3270,6 @@ PERL_CALLCONV void Perl_op_null(pTHX_ OP* o) #define PERL_ARGS_ASSERT_OP_NULL \ assert(o) -PERL_CALLCONV OP* Perl_op_parent(OP *o) - __attribute__nonnull__(1); -#define PERL_ARGS_ASSERT_OP_PARENT \ - assert(o) - PERL_CALLCONV OP* Perl_op_prepend_elem(pTHX_ I32 optype, OP* first, OP* last); PERL_CALLCONV void Perl_op_refcnt_lock(pTHX); PERL_CALLCONV void Perl_op_refcnt_unlock(pTHX); @@ -8033,6 +8028,13 @@ STATIC void S_mem_log_common(enum mem_log_type mlt, const UV n, const UV typesiz # endif #endif +#if defined(PERL_OP_PARENT) +PERL_CALLCONV OP* Perl_op_parent(OP *o) + __attribute__nonnull__(1); +#define PERL_ARGS_ASSERT_OP_PARENT \ + assert(o) + +#endif #if defined(PERL_USES_PL_PIDSTATUS) && defined(PERL_IN_UTIL_C) STATIC void S_pidgone(pTHX_ Pid_t pid, int status); #endif |