summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-02-29 04:53:00 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-02-29 04:53:00 +0000
commitba869debd80c55cfae8e9d4de0991d62f9efcb9b (patch)
tree73f5810de88203f0df413aee0bc7f3c94d686329 /util.c
parentd5c3ff09f505a33428a0772c6e16c91e1df4ce85 (diff)
downloadperl-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.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/util.c b/util.c
index 1525d53af1..1202b33d6a 100644
--- a/util.c
+++ b/util.c
@@ -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)
{