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 <n...@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.


Reply via email to