]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Revert "Stop checking whether environ is declared."
authorNick Mathewson <nickm@torproject.org>
Fri, 16 Dec 2016 17:16:52 +0000 (12:16 -0500)
committerNick Mathewson <nickm@torproject.org>
Fri, 16 Dec 2016 17:16:52 +0000 (12:16 -0500)
This reverts commit 954eeda619a59dae76144ad69967f0ed7341b564.

Apparently, OpenBSD is what expects you to declare environ
yourself.  So 19142 is a wontfix.

changes/19142 [deleted file]
configure.ac
src/common/compat.c

diff --git a/changes/19142 b/changes/19142
deleted file mode 100644 (file)
index 685bbbc..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-  o Removed features:
-    - We no longer attempt to build on systems where 'environ' is not
-      declared in the C headers. Closes ticket 19142.
index 552465c77c26dd90efe5719abdeb00400876a66b..fea884b2f4af22d8f8de89b5a3e332daef153f31 100644 (file)
@@ -1535,6 +1535,17 @@ int main(int c, char **v) { puts(__FUNCTION__); }])],
   tor_cv_have_FUNCTION_macro=yes,
   tor_cv_have_FUNCTION_macro=no))
 
+AC_CACHE_CHECK([whether we have extern char **environ already declared],
+  tor_cv_have_environ_declared,
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+int main(int c, char **v) { char **t = environ; }])],
+  tor_cv_have_environ_declared=yes,
+  tor_cv_have_environ_declared=no))
+
 if test "$tor_cv_have_func_macro" = "yes"; then
   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
 fi
@@ -1548,6 +1559,11 @@ if test "$tor_cv_have_FUNCTION_macro" = "yes"; then
            [Defined if the compiler supports __FUNCTION__])
 fi
 
+if test "$tor_cv_have_environ_declared" = "yes"; then
+  AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
+           [Defined if we have extern char **environ already declared])
+fi
+
 # $prefix stores the value of the --prefix command line option, or
 # NONE if the option wasn't set.  In the case that it wasn't set, make
 # it be the default, so that we can use it to expand directories now.
index 97d1fafbbb8d29ff604149281c4f6f16f1c17bdf..ebf05f59e1a23e7f4f6477e216660708dc161cab 100644 (file)
@@ -2390,6 +2390,15 @@ make_path_absolute(char *fname)
 #endif
 }
 
+#ifndef HAVE__NSGETENVIRON
+#ifndef HAVE_EXTERN_ENVIRON_DECLARED
+/* Some platforms declare environ under some circumstances, others don't. */
+#ifndef RUNNING_DOXYGEN
+extern char **environ;
+#endif
+#endif
+#endif
+
 /** Return the current environment. This is a portable replacement for
  * 'environ'. */
 char **