develooper Front page | perl.perl5.porters | Postings from February 2016

[perl #127619] Broken memcpy() fallback to bcopy()

Thread Previous
From:
Dagfinn Ilmari Mannsåker
Date:
February 26, 2016 16:05
Subject:
[perl #127619] Broken memcpy() fallback to bcopy()
Message ID:
rt-4.0.18-11614-1456502738-1033.127619-75-0@perl.org
# New Ticket Created by  Dagfinn Ilmari Mannsåker 
# Please include the string:  [perl #127619]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=127619 >


One of the Gentoo perl packagers (Andreas K. Huettel, dilfridge on #p5p)
discovered a problem compiling perl on arm with gcc 4.9.3:

@armv7a-hardfloat-linux-gnueabi-gcc -c -DPERL_CORE -fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -std=c89 -march=armv7-a -mtune=cortex-a9 -O2 -pipe -mfpu=vfpv3-d16 -mfloat-abi=hard -Wall -Werror=declaration-after-statement -Wextra -Wc++-compat -Wwrite-strings -fPIC -DPERL_IS_MINIPERL -DPERL_EXTERNAL_GLOB perlmini.c
op.c: In function 'Perl_block_start':
op.c:3898:5: error: invalid use of void expression
     PL_compiling.cop_warnings = DUP_WARNINGS(PL_compiling.cop_warnings);
     ^
op.c: In function 'Perl_newSTATEOP':
op.c:6704:5: error: invalid use of void expression
     cop->cop_warnings = DUP_WARNINGS(PL_curcop->cop_warnings);
     ^
op.c: In function 'Perl_newCONSTSUB_flags':
op.c:8990:3: error: invalid use of void expression
   PL_compiling.cop_warnings = DUP_WARNINGS(PL_curcop->cop_warnings);
   ^

A bit of digging turned up that for some reason Configure wasn't finding
memcpy():

$ egrep '^(mem|bcopy)' gentoo.fail.log 
bcopy() found.
memchr() found.
memcmp() found.
memcpy() NOT found.
memmove() found.
memset() found.

DUP_WARNINGS is defined in warnings.h in terms of CopyD , which is a
variant of Copy which returns the destination, which is defined in
handy.h in terms of memcpy, which is defined as bcopy() if HAS_MEMCPY is
false.

However, bcopy returns void, not void*, hence the above error.  The same
applies to MoveD, while ZeroD correctly handles it (but evaluates dest
twice):

#ifdef HAS_MEMSET
#define ZeroD(d,n,t)    (MEM_WRAP_CHECK_(n,t) memzero((char*)(d), (n) * sizeof(t)))
#else
/* Using bzero(), which returns void.  */
#define ZeroD(d,n,t)    (MEM_WRAP_CHECK_(n,t) memzero((char*)(d), (n) * sizeof(t)),d)
#endif

For systems that don't have bcopy or bzero either, there are alleged
"drop-in replacement[s]" in util.c, but trying to use these spews
warnings all over the place, because they use char* and I32 insted of
void* and size_t like they should.

Either we should make sure these fallbacks actually work, or we should
remove them and stop pretending we support systems without the mem*
functions.

-- 
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
 the consequences of."                              -- Skud's Meta-Law


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About