diff options
author | Karl Williamson <khw@cpan.org> | 2023-02-02 18:11:26 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2023-03-01 17:00:52 -0700 |
commit | 32346b7cdde5bcf8a0c8c9ee89ef541d8fe9a7b7 (patch) | |
tree | c1c1d1654e828dff1e17af76834bb73383a0f114 /inline.h | |
parent | 4a7bea40c45452cd472c087fe36c369a1b5ffc36 (diff) | |
download | perl-32346b7cdde5bcf8a0c8c9ee89ef541d8fe9a7b7.tar.gz |
Inline get_context() for non-Win32
This trivial function should get optimized out. But I couldn't get it
to work for Windows, because the two likely hdr files don't have
PL_thr_key defined in them. I suppose a new hdr file could be created
that gets included later. But I didn't think it was worth it.
Diffstat (limited to 'inline.h')
-rw-r--r-- | inline.h | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -3652,6 +3652,39 @@ Perl_savesharedsvpv(pTHX_ SV *sv) return savesharedpvn(pv, len); } +#ifndef PERL_GET_CONTEXT_DEFINED + +/* +=for apidoc_section $embedding +=for apidoc get_context + +Implements L<perlapi/C<PERL_GET_CONTEXT>>, which you should use instead. + +=cut +*/ + +PERL_STATIC_INLINE void * +Perl_get_context(void) +{ +# if defined(USE_ITHREADS) +# ifdef OLD_PTHREADS_API + pthread_addr_t t; + int error = pthread_getspecific(PL_thr_key, &t); + if (error) + Perl_croak_nocontext("panic: pthread_getspecific, error=%d", error); + return (void*)t; +# elif defined(I_MACH_CTHREADS) + return (void*)cthread_data(cthread_self()); +# else + return (void*)PTHREAD_GETSPECIFIC(PL_thr_key); +# endif +# else + return (void*)NULL; +# endif +} + +#endif + PERL_STATIC_INLINE MGVTBL* Perl_get_vtbl(pTHX_ int vtbl_id) { |