This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
amigaos4: use our own environ implementation
authorAndy Broad <andy@broad.ology.org.uk>
Thu, 27 Aug 2015 13:31:34 +0000 (09:31 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 5 Sep 2015 15:12:45 +0000 (11:12 -0400)
perl.h
unixish.h
util.c

diff --git a/perl.h b/perl.h
index 9178dfc..9ff2015 100644 (file)
--- a/perl.h
+++ b/perl.h
 /* 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 */
index fe6d003..2f0d8f3 100644 (file)
--- a/unixish.h
+++ b/unixish.h
 #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 c2df74d..5bc3aa5 100644 (file)
--- 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 */