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

[Perl/perl5] 7b2136: For C++ extensions, use the pthreads definitionof...

Nicholas Clark via perl5-changes
January 7, 2022 20:13
[Perl/perl5] 7b2136: For C++ extensions, use the pthreads definitionof...
Message ID:
  Branch: refs/heads/smoke-me/nicholas/pthreads-not-_Thread_local-for-C++
  Commit: 7b21363d3b21abf1e0e89b026c7bd25a3aaeefdc
  Author: Nicholas Clark <>
  Date:   2022-01-07 (Fri, 07 Jan 2022)

  Changed paths:
    M thread.h

  Log Message:
  For C++ extensions, use the pthreads definition of PERL_GET_CONTEXT

Configure probes the C compiler to find out whether it supports C11 thread
local storage, and if found uses this for PERL_SET_CONTEXT/PERL_GET_CONTEXT,
in preference to the pthread_setspecific()/pthread_getspecific() approach.

However, we can come unstuck with XS extensions written in C++, as C++ and C
disagree on the syntax used for thread local storage, meaning that the
working token that Configure probed for C turns out to be a compiler error
on C++.

As Configure doesn't have a way to probe for C++ dialects, we just take the
safe option and do the same as 5.34.0 and earlier - use pthreads on C++.

This commit is minimal because the implementation of PERL_SET_CONTEXT for
C11 thread local storage was already defensively written to *also* call
pthread_setspecific(). Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About