Skip to content

Commit e2cb835

Browse files
authored
Merge pull request #79216 from compnerd/android-env
runtime: tweak the environment handling
2 parents 46bd549 + db160d5 commit e2cb835

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

stdlib/public/runtime/EnvironmentVariables.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ void printHelp(const char *extra) {
173173
// Initialization code.
174174
swift::once_t swift::runtime::environment::initializeToken;
175175

176-
#if SWIFT_STDLIB_HAS_ENVIRON && (defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__))
176+
#if SWIFT_STDLIB_HAS_ENVIRON
177+
178+
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__)
177179
extern "C" char **environ;
178180
#define ENVIRON environ
179181
#elif defined(_WIN32)
@@ -213,11 +215,11 @@ static void platformInitialize(void *context) {
213215
}
214216
#endif
215217

216-
#if !SWIFT_STDLIB_HAS_ENVIRON
217-
void swift::runtime::environment::initialize(void *context) {
218-
platformInitialize(context);
219-
}
220-
#elif defined(ENVIRON)
218+
#endif
219+
220+
#if SWIFT_STDLIB_HAS_ENVIRON
221+
222+
#if defined(ENVIRON)
221223
void swift::runtime::environment::initialize(void *context) {
222224
// On platforms where we have an environment variable array available, scan it
223225
// directly. This optimizes for the common case where no variables are set,
@@ -295,6 +297,11 @@ void swift::runtime::environment::initialize(void *context) {
295297
}
296298
#endif
297299

300+
#else
301+
void swift::runtime::environment::initialize(void *context) {
302+
}
303+
#endif
304+
298305
SWIFT_RUNTIME_EXPORT
299306
bool swift_COWChecksEnabled() {
300307
return runtime::environment::SWIFT_DEBUG_ENABLE_COW_CHECKS();

0 commit comments

Comments
 (0)