Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse code from defined macro #15901

Closed
p5pRT opened this issue Mar 1, 2017 · 9 comments
Closed

Reuse code from defined macro #15901

p5pRT opened this issue Mar 1, 2017 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 1, 2017

Migrated from rt.perl.org#130893 (status was 'resolved')

Searchable as RT130893$

@p5pRT
Copy link
Author

p5pRT commented Mar 1, 2017

From @KES777

Created by @KES777

Hi.

The same code `sv_setuv(PUSHmortal, (UV)(u))` is seen in `mPUSH*` macro.

We may reuse it like mPUSHp does

$cat 0001-Reuse-defined-macro.patch
From 4110fac479be5e7101d800c14ebcd04f1a133863 Mon Sep 17 00​:00​:00 2001
From​: Eugen Konkov <kes-kes@​yandex.ru>
Date​: Wed, 1 Mar 2017 23​:28​:04 +0200
Subject​: [PATCH] Reuse code from defined macro

---
pp.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

Inline Patch
diff --git a/pp.h b/pp.h
index 3b8f36f..16cb937 100644
--- a/pp.h
+++ b/pp.h
@@ -443,9 +443,9 @@ Does not use C<TARG>.  See also C<L</XPUSHu>>, C<L</mPUSHu>> and C<L</PUSHu>>.
 #define mXPUSHs(s) XPUSHs(sv_2mortal(s))
 #define XPUSHmortal    XPUSHs(sv_newmortal())
 #define mXPUSHp(p,l)   STMT_START { EXTEND(sp,1); mPUSHp((p), (l)); } STMT_END
-#define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END
-#define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END
-#define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END
+#define mXPUSHn(n) STMT_START { EXTEND(sp,1); mPUSHn(n); } STMT_END
+#define mXPUSHi(i) STMT_START { EXTEND(sp,1); mPUSHi(i); } STMT_END
+#define mXPUSHu(u) STMT_START { EXTEND(sp,1); mPUSHu(u); } STMT_END

 #define SETs(s)        (*sp = s)
 #define SETTARG        STMT_START { SvSETMAGIC(TARG); SETs(TARG); } STMT_END
--
2.7.4
Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.24.0:

Configured by kes at Tue Jun  7 00:21:02 EEST 2016.

Summary of my perl5 (revision 5 version 24 subversion 0) configuration:
   
  Platform:
    osname=linux, osvers=3.13.0-37-generic, archname=x86_64-linux
    uname='linux kes-desktop 3.13.0-37-generic #64-ubuntu smp mon sep 22 21:28:38 utc 2014 x86_64 x86_64 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/kes/perl5/perlbrew/perls/perl-5.24.0 -Aeval:scriptdir=/home/kes/perl5/perlbrew/perls/perl-5.24.0/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.8.4', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.19'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    Devel::PatchPerl 1.38


@INC for perl 5.24.0:
    /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/x86_64-linux
    /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0
    /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/x86_64-linux
    /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0
    .


Environment for perl 5.24.0:
    HOME=/home/kes
    LANG=en_US.UTF-8
    LANGUAGE=en
    LC_ADDRESS=uk_UA.UTF-8
    LC_IDENTIFICATION=uk_UA.UTF-8
    LC_MEASUREMENT=uk_UA.UTF-8
    LC_MESSAGES=en_US.UTF-8
    LC_MONETARY=uk_UA.UTF-8
    LC_NAME=uk_UA.UTF-8
    LC_NUMERIC=uk_UA.UTF-8
    LC_PAPER=uk_UA.UTF-8
    LC_TELEPHONE=uk_UA.UTF-8
    LC_TIME=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.24.0/bin:/home/kes/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    PERLBREW=command perlbrew
    PERLBREW_BASHRC_VERSION=0.78
    PERLBREW_HOME=/home/kes/.perlbrew
    PERLBREW_MANPATH=/home/kes/perl5/perlbrew/perls/perl-5.24.0/man
    PERLBREW_PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.24.0/bin
    PERLBREW_PERL=perl-5.24.0
    PERLBREW_ROOT=/home/kes/perl5/perlbrew
    PERLBREW_VERSION=0.78
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Mar 2, 2017

From @jkeenan

On Wed, 01 Mar 2017 22​:49​:57 GMT, kes-kes@​yandex.ru wrote​:

Cc​: kes-kes@​yandex.ru
Subject​: Reuse code from defined macro
From​: kes-kes@​yandex.ru
To​: perlbug@​perl.org
Message-Id​: <5.24.0_18677_1488408375@​kes-desktop>
Reply-To​: kes-kes@​yandex.ru

This is a bug report for perl from kes-kes@​yandex.ru,
generated with the help of perlbug 1.40 running under perl 5.24.0.

Converting patch to attachment.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Mar 2, 2017

From @jkeenan

130893-0001-Reuse-defined-macro.patch
From 4110fac479be5e7101d800c14ebcd04f1a133863 Mon Sep 17 00:00:00 2001
From: Eugen Konkov <kes-kes@yandex.ru>
Date: Wed, 1 Mar 2017 23:28:04 +0200
Subject: [PATCH] Reuse code from defined macro

---
 pp.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pp.h b/pp.h
index 3b8f36f..16cb937 100644
--- a/pp.h
+++ b/pp.h
@@ -443,9 +443,9 @@ Does not use C<TARG>.  See also C<L</XPUSHu>>, C<L</mPUSHu>> and C<L</PUSHu>>.
 #define mXPUSHs(s) XPUSHs(sv_2mortal(s))
 #define XPUSHmortal    XPUSHs(sv_newmortal())
 #define mXPUSHp(p,l)   STMT_START { EXTEND(sp,1); mPUSHp((p), (l)); } STMT_END
-#define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END
-#define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END
-#define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END
+#define mXPUSHn(n) STMT_START { EXTEND(sp,1); mPUSHn(n); } STMT_END
+#define mXPUSHi(i) STMT_START { EXTEND(sp,1); mPUSHi(i); } STMT_END
+#define mXPUSHu(u) STMT_START { EXTEND(sp,1); mPUSHu(u); } STMT_END

 #define SETs(s)        (*sp = s)
 #define SETTARG        STMT_START { SvSETMAGIC(TARG); SETs(TARG); } STMT_END
--
2.7.4

@p5pRT
Copy link
Author

p5pRT commented Mar 2, 2017

From [Unknown Contact. See original ticket]

On Wed, 01 Mar 2017 22​:49​:57 GMT, kes-kes@​yandex.ru wrote​:

Cc​: kes-kes@​yandex.ru
Subject​: Reuse code from defined macro
From​: kes-kes@​yandex.ru
To​: perlbug@​perl.org
Message-Id​: <5.24.0_18677_1488408375@​kes-desktop>
Reply-To​: kes-kes@​yandex.ru

This is a bug report for perl from kes-kes@​yandex.ru,
generated with the help of perlbug 1.40 running under perl 5.24.0.

Converting patch to attachment.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Jun 1, 2017

From @jkeenan

On Thu, 02 Mar 2017 01​:23​:53 GMT, jkeenan wrote​:

On Wed, 01 Mar 2017 22​:49​:57 GMT, kes-kes@​yandex.ru wrote​:

Cc​: kes-kes@​yandex.ru
Subject​: Reuse code from defined macro
From​: kes-kes@​yandex.ru
To​: perlbug@​perl.org
Message-Id​: <5.24.0_18677_1488408375@​kes-desktop>
Reply-To​: kes-kes@​yandex.ru

This is a bug report for perl from kes-kes@​yandex.ru,
generated with the help of perlbug 1.40 running under perl 5.24.0.

Converting patch to attachment.

Post code-freeze, I tried to apply the patch. I had to convert the whitespace before 'STMT' to a hard tab to match the existing code. Once, I started to run 'make', however, I got compiler (gcc) warnings like these​:

#####
pp.h​:449​:0​: warning​: "mXPUSHn" redefined
#define mXPUSHn(n) STMT_START { EXTEND(sp,1); mPUSHn(n); } STMT_END
^
pp.h​:446​:0​: note​: this is the location of the previous definition
#define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END
^
pp.h​:450​:0​: warning​: "mXPUSHi" redefined
#define mXPUSHi(i) STMT_START { EXTEND(sp,1); mPUSHi(i); } STMT_END
^
pp.h​:447​:0​: note​: this is the location of the previous definition
#define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END
^
pp.h​:451​:0​: warning​: "mXPUSHu" redefined
#define mXPUSHu(u) STMT_START { EXTEND(sp,1); mPUSHu(u); } STMT_END
^
pp.h​:448​:0​: note​: this is the location of the previous definition
#define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END
^
#####

We managed to clean up all compiler warnings during a regular gcc 'make' for perl-5.26.0. So I consider this patch to be a regression and not ready for application.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Jun 1, 2017

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 1, 2017

@jkeenan - Status changed from 'open' to 'rejected'

@p5pRT
Copy link
Author

p5pRT commented Jun 5, 2017

@iabyn - Status changed from 'rejected' to 'resolved'

@p5pRT p5pRT closed this as completed Jun 5, 2017
@p5pRT
Copy link
Author

p5pRT commented Jun 5, 2017

From @iabyn

On Thu, Jun 01, 2017 at 08​:50​:09AM -0700, James E Keenan via RT wrote​:

On Thu, 02 Mar 2017 01​:23​:53 GMT, jkeenan wrote​:

On Wed, 01 Mar 2017 22​:49​:57 GMT, kes-kes@​yandex.ru wrote​:

Cc​: kes-kes@​yandex.ru
Subject​: Reuse code from defined macro
From​: kes-kes@​yandex.ru
To​: perlbug@​perl.org
Message-Id​: <5.24.0_18677_1488408375@​kes-desktop>
Reply-To​: kes-kes@​yandex.ru

This is a bug report for perl from kes-kes@​yandex.ru,
generated with the help of perlbug 1.40 running under perl 5.24.0.

Converting patch to attachment.

Post code-freeze, I tried to apply the patch. I had to convert the whitespace before 'STMT' to a hard tab to match the existing code. Once, I started to run 'make', however, I got compiler (gcc) warnings like these​:

#####
pp.h​:449​:0​: warning​: "mXPUSHn" redefined
#define mXPUSHn(n) STMT_START { EXTEND(sp,1); mPUSHn(n); } STMT_END
^
pp.h​:446​:0​: note​: this is the location of the previous definition
#define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END
^
pp.h​:450​:0​: warning​: "mXPUSHi" redefined
#define mXPUSHi(i) STMT_START { EXTEND(sp,1); mPUSHi(i); } STMT_END
^
pp.h​:447​:0​: note​: this is the location of the previous definition
#define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END
^
pp.h​:451​:0​: warning​: "mXPUSHu" redefined
#define mXPUSHu(u) STMT_START { EXTEND(sp,1); mPUSHu(u); } STMT_END
^
pp.h​:448​:0​: note​: this is the location of the previous definition
#define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END
^
#####

We managed to clean up all compiler warnings during a regular gcc 'make' for perl-5.26.0. So I consider this patch to be a regression and not ready for application.

I think something went wrong when you applied the patch - you got left
with both the old and new macro definitions.

I've applied the patch by hand as v5.27.0-98-g2ca72cb, and it compiles
without warnings.

So "thanks, applied".

--
Red sky at night - gerroff my land!
Red sky at morning - gerroff my land!
  -- old farmers' sayings #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant