diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-29 04:53:00 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-29 04:53:00 +0000 |
commit | ba869debd80c55cfae8e9d4de0991d62f9efcb9b (patch) | |
tree | 73f5810de88203f0df413aee0bc7f3c94d686329 /util.c | |
parent | d5c3ff09f505a33428a0772c6e16c91e1df4ce85 (diff) | |
download | perl-ba869debd80c55cfae8e9d4de0991d62f9efcb9b.tar.gz |
support fetching current interpreter from TLS under useithreads
p4raw-id: //depot/perl@5342
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 42 |
1 files changed, 30 insertions, 12 deletions
@@ -3291,8 +3291,38 @@ Perl_find_script(pTHX_ char *scriptname, bool dosearch, char **search_ext, I32 f return (scriptname ? savepv(scriptname) : Nullch); } +#ifndef PERL_GET_CONTEXT_DEFINED + +void * +Perl_get_context(void) +{ +#if defined(USE_THREADS) || defined(USE_ITHREADS) +# ifdef OLD_PTHREADS_API + pthread_addr_t t; + if (pthread_getspecific(PL_thr_key, &t)) + Perl_croak_nocontext("panic: pthread_getspecific"); + return (void*)t; +# else + return (void*)pthread_getspecific(PL_thr_key); +# endif +#else + return (void*)NULL; +#endif +} + +void +Perl_set_context(void *t) +{ +#if defined(USE_THREADS) || defined(USE_ITHREADS) + if (pthread_setspecific(PL_thr_key, t)) + Perl_croak_nocontext("panic: pthread_setspecific"); +#endif +} + +#endif /* !PERL_GET_CONTEXT_DEFINED */ #ifdef USE_THREADS + #ifdef FAKE_THREADS /* Very simplistic scheduler for now */ void @@ -3367,18 +3397,6 @@ Perl_cond_wait(pTHX_ perl_cond *cp) } #endif /* FAKE_THREADS */ -#ifdef PTHREAD_GETSPECIFIC_INT -struct perl_thread * -Perl_getTHR(pTHX) -{ - pthread_addr_t t; - - if (pthread_getspecific(PL_thr_key, &t)) - Perl_croak(aTHX_ "panic: pthread_getspecific"); - return (struct perl_thread *) t; -} -#endif - MAGIC * Perl_condpair_magic(pTHX_ SV *sv) { |