summaryrefslogtreecommitdiff
path: root/perl.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-02-20 16:51:31 -0700
committerKarl Williamson <khw@cpan.org>2020-03-11 09:52:11 -0600
commit2bc5f86adf5f1c0feb76d83e1a627e5649e6beab (patch)
tree77b9b2120fd2d2a0173cfb978f2f20df5afa41e3 /perl.h
parentb6d9446cecd87d16450d8743a2f0b0079e12567b (diff)
downloadperl-2bc5f86adf5f1c0feb76d83e1a627e5649e6beab.tar.gz
Add mutex for accessing ENV
Diffstat (limited to 'perl.h')
-rw-r--r--perl.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/perl.h b/perl.h
index b8f697240c..c734548771 100644
--- a/perl.h
+++ b/perl.h
@@ -2907,6 +2907,21 @@ typedef struct padname PADNAME;
# define USE_ENVIRON_ARRAY
#endif
+#ifdef USE_ITHREADS
+ /* On some platforms it would be safe to use a read/write mutex with many
+ * readers possible at the same time. On other platforms, notably IBM ones,
+ * subsequent getenv calls destroy earlier ones. Those platforms would not
+ * be able to handle simultaneous getenv calls */
+# define ENV_LOCK MUTEX_LOCK(&PL_env_mutex)
+# define ENV_UNLOCK MUTEX_UNLOCK(&PL_env_mutex)
+# define ENV_INIT MUTEX_INIT(&PL_env_mutex);
+# define ENV_TERM MUTEX_DESTROY(&PL_env_mutex);
+#else
+# define ENV_LOCK NOOP;
+# define ENV_UNLOCK NOOP;
+# define ENV_INIT NOOP;
+# define ENV_TERM NOOP;
+#endif
#if defined(HAS_SIGACTION) && defined(SA_SIGINFO)
/* having sigaction(2) means that the OS supports both 1-arg and 3-arg