develooper Front page | perl.perl5.changes | Postings from January 2022

[Perl/perl5] f14078: PERL_SET_CONTEXT(t) needs to setPL_current_contex...

From:
Nicholas Clark via perl5-changes
Date:
January 8, 2022 21:44
Subject:
[Perl/perl5] f14078: PERL_SET_CONTEXT(t) needs to setPL_current_contex...
Message ID:
Perl/perl5/push/refs/heads/smoke-me/nicholas/pthreads-not-_Thread_local-for-C++/7b2136-f14078@github.com
  Branch: refs/heads/smoke-me/nicholas/pthreads-not-_Thread_local-for-C++
  Home:   https://github.com/Perl/perl5
  Commit: f140784ba87c5f5006a3eee059af4afee2e0fda7
      https://github.com/Perl/perl5/commit/f140784ba87c5f5006a3eee059af4afee2e0fda7
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2022-01-08 (Sat, 08 Jan 2022)

  Changed paths:
    M thread.h
    M util.c

  Log Message:
  -----------
  PERL_SET_CONTEXT(t) needs to set PL_current_context from C++ too

We want to use C11 thread local storage where possible, as its read overhead
is lower. However C++ uses incompatible syntax for TLS, so we have to hide
the variable from C++ extensions, and have the read code "fall back" to the
pthread_getspecific() approach.

However, C++ extensions also need to be able to call PERL_SET_CONTEXT(t) and
have everything still work the same as C extensions. Hence they *also* need
to set PL_current_context - a variable that has to be hidden from them.
Hence change the version of the PERL_SET_CONTEXT macro used by C++
extensions from inline code to a call to Perl_set_context(), and have that
set PL_current_context (when used).

Technically this commit also fixes a bug in that Perl_set_context() is API
and should have been setting PL_current_context since that variable was
first introduced. In practice, likely nothing uses this API, as there is no
code on CPAN that calls it, and the macro PERL_SET_CONTEXT() is much more
prominent.





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