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

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

Nicholas Clark via perl5-changes
January 4, 2022 18:48
[Perl/perl5] ec238e: For C++ extensions, use the pthreads definitionof...
Message ID:
  Branch: refs/heads/smoke-me/nicholas/pthreads-not-_Thread_local-for-C++
  Commit: ec238e5dff1c782cf69f109443a52540711b08d9
  Author: Nicholas Clark <>
  Date:   2022-01-04 (Tue, 04 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 on some
platforms the C++ compiler can use different syntax for thread local storage.
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