Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Miles <robertmiles3@users.noreply.github.com>2018-08-13 22:27:11 +0300
committerJan Kotas <jkotas@microsoft.com>2018-08-13 22:27:10 +0300
commit9b17c1edb9d8d826c666693ab1b8ee05f77bd0b7 (patch)
tree8002a64c50c027b1c930da5a63af70d46935a4a0 /src/Native
parent32226df5b1067717417a0ac0b64b7b0b0271f63e (diff)
Add environment variables support for Unix (#6216)
Diffstat (limited to 'src/Native')
-rw-r--r--src/Native/System.Private.CoreLib.Native/config.h.in1
-rw-r--r--src/Native/System.Private.CoreLib.Native/configure.cmake3
-rw-r--r--src/Native/System.Private.CoreLib.Native/pal_environment.cpp17
3 files changed, 21 insertions, 0 deletions
diff --git a/src/Native/System.Private.CoreLib.Native/config.h.in b/src/Native/System.Private.CoreLib.Native/config.h.in
index c7c3aafd9..3c3f11298 100644
--- a/src/Native/System.Private.CoreLib.Native/config.h.in
+++ b/src/Native/System.Private.CoreLib.Native/config.h.in
@@ -6,3 +6,4 @@
#cmakedefine01 HAVE_MACH_ABSOLUTE_TIME
#cmakedefine01 HAVE_SCHED_GETCPU
#cmakedefine01 HAVE_GNU_LIBNAMES_H
+#cmakedefine01 HAVE__NSGETENVIRON \ No newline at end of file
diff --git a/src/Native/System.Private.CoreLib.Native/configure.cmake b/src/Native/System.Private.CoreLib.Native/configure.cmake
index aaabb387c..1fbbf9c5e 100644
--- a/src/Native/System.Private.CoreLib.Native/configure.cmake
+++ b/src/Native/System.Private.CoreLib.Native/configure.cmake
@@ -1,6 +1,7 @@
include(CheckCXXSourceCompiles)
include(CheckCXXSourceRuns)
include(CheckLibraryExists)
+include(CheckFunctionExists)
check_library_exists(pthread pthread_condattr_setclock "" HAVE_PTHREAD_CONDATTR_SETCLOCK)
@@ -62,6 +63,8 @@ set(CMAKE_REQUIRED_LIBRARIES)
check_include_files(gnu/lib-names.h HAVE_GNU_LIBNAMES_H)
+check_function_exists(_NSGetEnviron HAVE__NSGETENVIRON)
+
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
diff --git a/src/Native/System.Private.CoreLib.Native/pal_environment.cpp b/src/Native/System.Private.CoreLib.Native/pal_environment.cpp
index 94660baba..15ef90c34 100644
--- a/src/Native/System.Private.CoreLib.Native/pal_environment.cpp
+++ b/src/Native/System.Private.CoreLib.Native/pal_environment.cpp
@@ -10,6 +10,9 @@
#if HAVE_SCHED_GETCPU
#include <sched.h>
#endif
+#if HAVE__NSGETENVIRON
+#include <crt_externs.h>
+#endif
extern "C" char* CoreLibNative_GetEnv(const char* variable)
@@ -30,3 +33,17 @@ extern "C" void CoreLibNative_Exit(int32_t exitCode)
{
exit(exitCode);
}
+
+extern "C" char** CoreLibNative_GetEnviron()
+{
+ char** sysEnviron;
+
+#if HAVE__NSGETENVIRON
+ sysEnviron = *(_NSGetEnviron());
+#else // HAVE__NSGETENVIRON
+ extern char **environ;
+ sysEnviron = environ;
+#endif // HAVE__NSGETENVIRON
+
+ return sysEnviron;
+} \ No newline at end of file