summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Broad <andy@broad.ology.org.uk>2015-08-27 09:31:34 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2015-09-05 11:12:45 -0400
commit6e3136a65af8652c1ee695f86642438ada8d82cb (patch)
treeb87c4a7d39a08d38b7f9c61ab8dc3d63fa01ce59
parent5ce45b7bbc7aa6b7aeb0db6c6a7faa07a30bff04 (diff)
downloadperl-6e3136a65af8652c1ee695f86642438ada8d82cb.tar.gz
amigaos4: use our own environ implementation
-rw-r--r--perl.h9
-rw-r--r--unixish.h5
-rw-r--r--util.c11
3 files changed, 23 insertions, 2 deletions
diff --git a/perl.h b/perl.h
index 9178dfc535..9ff2015544 100644
--- a/perl.h
+++ b/perl.h
@@ -778,6 +778,15 @@
/* If this causes problems, set i_unistd=undef in the hint file. */
#ifdef I_UNISTD
# include <unistd.h>
+# if defined(__amigaos4__)
+/* Under AmigaOS 4 newlib.library provides an environ. However using
+ * it doesn't give us enough control over inheritance of variables by
+ * subshells etc. so replace with custom version based on abc-shell
+ * code. */
+extern char **myenviron;
+# undef environ
+# define environ myenviron
+# endif
#endif
/* for WCOREDUMP */
diff --git a/unixish.h b/unixish.h
index fe6d003edd..2f0d8f3b9f 100644
--- a/unixish.h
+++ b/unixish.h
@@ -129,11 +129,12 @@
#if defined(__amigaos4__)
void amigaos4_init_fork_array();
void amigaos4_dispose_fork_array();
+void amigaos4_init_environ_sema();
# define PERL_SYS_INIT_BODY(c,v) \
- MALLOC_CHECK_TAINT2(*c,*v) PERL_FPU_INIT; PERLIO_INIT; MALLOC_INIT; amigaos4_init_fork_array();
+ MALLOC_CHECK_TAINT2(*c,*v) PERL_FPU_INIT; PERLIO_INIT; MALLOC_INIT; amigaos4_init_fork_array(); amigaos4_init_environ_sema();
# define PERL_SYS_TERM_BODY() \
HINTS_REFCNT_TERM; OP_CHECK_MUTEX_TERM; \
- OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM; amigaos4_dispose_fork_array();
+ OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM; amigaos4_dispose_fork_array();
#endif
#ifndef PERL_SYS_INIT_BODY
diff --git a/util.c b/util.c
index c2df74d929..5bc3aa5473 100644
--- a/util.c
+++ b/util.c
@@ -2055,6 +2055,9 @@ void
Perl_my_setenv(pTHX_ const char *nam, const char *val)
{
dVAR;
+#if defined(__amigaos4__)
+ amigaos4_obtain_environ(__FUNCTION__);
+#endif
#ifdef USE_ITHREADS
/* only parent thread can modify process environment */
if (PL_curinterp == aTHX)
@@ -2096,7 +2099,11 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val)
environ[i] = environ[i+1];
i++;
}
+#if defined(__amigaos4__)
+ goto my_setenv_out;
+#else
return;
+#endif
}
if (!environ[i]) { /* does not exist yet */
environ = (char**)safesysrealloc(environ, (i+2) * sizeof(char*));
@@ -2157,6 +2164,10 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val)
}
#endif
}
+#if defined(__amigaos4__)
+my_setenv_out:
+ amigaos4_release_environ(__FUNCTION__);
+#endif
}
#else /* WIN32 || NETWARE */