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

Inconsistencies in memory size types

Thread Next
March 1, 2016 09:46
Inconsistencies in memory size types
Message ID:
Hi porters,

While investigating [perl #127619] Broken memcpy() fallback to bcopy(),
I noticed that variables refering to string lengths, array sizes
etc. are an inconsistent mess of MEM_SIZE, STRLEN, Size_t and size_t
(and SSize_t/ssize_t for signed variants).  A bit more digging reveals
that we already use size_t unconditionally all over the codebase (and
it's required by C89), while ssize_t support is more patchy (it's only
required by POSIX, not ISO/ANSI C).

In light of this, I've altered Configure and friends to not probe for
size_t, and changed SSize_t to ssize_t (guarded by an #ifndef, in case
it's a #define rather than a typedef) in config_h.SH, and changed uses
of MEM_SIZE, STRLEN and Size_t to size_t and SSize_t to ssize_t.  I have
not touched cpan/, and the existing names are still there, guarded by
#ifndef PERL_CORE.

I've pushed the result to smoke-me/ilmari/size_t, and the results so far
look good.  I realise we are approaching full code freeze, so I'm a bit
wary of merging it, but I think it's a clean-up overall, and keeping
rebasing it for an extended time would be a pain.

What say ye?

commit 33bf7414d386dc2895cc0ef78e40fc0667b52262
Author: Dagfinn Ilmari Mannsåker <>
Date:   2016-02-26 17:42:48 +0000

    Use (s)size_t constitently
    size_t exists everywhere, but not ssize_t, so keep the probing for
    that (but call the type ssize_t, not SSize_t).
    Keep the old typenames for non-PERL_CORE.

 209 files changed, 2891 insertions(+), 2932 deletions(-)

"I use RMS as a guide in the same way that a boat captain would use
 a lighthouse.  It's good to know where it is, but you generally
 don't want to find yourself in the same spot." - Tollef Fog Heen

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About