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

[perl #121351] Replace use of PL_statbuf and PL_timesbuf with auto variables

Thread Next
Nicholas Clark
February 28, 2014 16:19
[perl #121351] Replace use of PL_statbuf and PL_timesbuf with auto variables
Message ID:
# New Ticket Created by  Nicholas Clark 
# Please include the string:  [perl #121351]
# in the subject line of all future correspondence about this issue. 
# <URL: >

intrpvar.h contains these two lines:

PERLVAR(I, statbuf,	Stat_t)


PERLVAR(I, timesbuf,	struct tms)

(Note that the stat struct used to implement _ is in PL_statcache,
which is not the same as PL_statbuf)

These variables are not used to pass any state between functions in
the perl core, and aren't (meaningfully) used by any modules on CPAN:

(note that PAR-Packer must already work just fine without PL_statbuf,
as PL_statbuf is *not* a macro on an unthreaded perl, and so its
#ifndef PL_statbuf code will already be used)

These seem to be vestiges of Perl 1, which has this in its perl.h:

EXT struct stat statbuf;
EXT struct tms timesbuf;

I asked Larry if he remembered why:

16:05 < nwc10> TimToady: in perl 1, why does it have EXT struct stat statbuf; and EXT struct tms timesbuf; in perl.h, rather than using local variables in functions? Was there some compiler back then that screwed up allocating structs on the stack?
16:09 < TimToady> Don't recall, but I suspect it's just because the stat manpage had 'extern struct stat statbuf'
16:09 < nwc10> aha thanks

I think that we should abolish these two variables, and replace them
with local auto variables in functions that use them.

I think that we shouldn't do this before v5.20.0 escapes.

Given the complete lack of CPAN usage, I'm also not sure whether we
should deprecate them, or just remove them. I think that we don't
actually yet have a way to add C compiler annotations in intrpvar.h,
but we probably could fix that if needed.

Nicholas Clark

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