summaryrefslogtreecommitdiff
path: root/globals.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-06-20 17:24:15 +0000
committerTony Cook <tony@develop-help.com>2021-09-07 15:46:16 +1000
commit3683a9ee5ad61f8cb5eac30e61b4936bd0445bdb (patch)
tree8ed6466fad66406cddf2e95282cbd438a9846271 /globals.c
parent65f7068160bfc9a3f4b195a579c881188cc4fff3 (diff)
downloadperl-3683a9ee5ad61f8cb5eac30e61b4936bd0445bdb.tar.gz
If we have thread local storage, use it instead of posix_getspecific().
Declare and use a variable PL_current_context to store a pointer to the thread's interpreter struct. Use this to implement implicit context undef ITHREADS, instead of a call to posix_getspecific(). For normal threaded code, this will eliminate function calls. For threaded code in shared objects (the typical configuration for Linux distribution builds) there still needs to be a function call to get the pointer to thread local variables, but there will only be one per function, not one per read of the variable.
Diffstat (limited to 'globals.c')
-rw-r--r--globals.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/globals.c b/globals.c
index 045c71ca3f..5a78c81166 100644
--- a/globals.c
+++ b/globals.c
@@ -30,6 +30,14 @@
*/
#include "regcomp.h"
+/* We need somewhere to declare this. This file seems a good place.
+ * This is not a regular "global" in that we don't know whether it needs to
+ * exist until we include threads.h, and we don't want it as part of any
+ * global struct (if that or something similar is re-introduced. */
+
+#if defined(USE_ITHREADS) && defined(PERL_THREAD_LOCAL)
+PERL_THREAD_LOCAL void *PL_current_context;
+#endif
/*
* ex: set ts=8 sts=4 sw=4 et: