Skip to content

Commit 3251df8

Browse files
committed
[Concurrency] Don't use getenv() unless SWIFT_STDLIB_HAS_ENVIRON is set.
We don't necessarily have environment variables, which is why we have SWIFT_STDLIB_HAS_ENVIRON. Calling getenv() outside of a check of this means Concurrency won't work in environments where getenv() cannot be used. rdar://91050064
1 parent 230c435 commit 3251df8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,15 @@ static bool swift_task_isCurrentExecutorImpl(ExecutorRef executor) {
332332
static unsigned unexpectedExecutorLogLevel = 1;
333333

334334
static void checkUnexpectedExecutorLogLevel(void *context) {
335+
#if SWIFT_STDLIB_HAS_ENVIRON
335336
const char *levelStr = getenv("SWIFT_UNEXPECTED_EXECUTOR_LOG_LEVEL");
336337
if (!levelStr)
337338
return;
338339

339340
long level = strtol(levelStr, nullptr, 0);
340341
if (level >= 0 && level < 3)
341342
unexpectedExecutorLogLevel = level;
343+
#endif // SWIFT_STDLIB_HAS_ENVIRON
342344
}
343345

344346
SWIFT_CC(swift)

0 commit comments

Comments
 (0)