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
From:
Nicholas Clark
Date:
February 28, 2014 16:19
Subject:
[perl #121351] Replace use of PL_statbuf and PL_timesbuf with auto variables
Message ID:
rt-4.0.18-31234-1393604350-507.121351-75-0@perl.org
# New Ticket Created by  Nicholas Clark 
# Please include the string:  [perl #121351]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=121351 >


intrpvar.h contains these two lines:

PERLVAR(I, statbuf,	Stat_t)

and

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:

http://grep.cpan.me/?q=PL_statbuf
http://grep.cpan.me/?q=PL_timesbuf

(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

http://irclog.perlgeek.de/perl6/2014-02-28#i_8363520


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


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