Skip to content

Commit 9611253

Browse files
authored
[Concurrency] Make error logging more robust (swiftlang#63383)
rdar://104967560
1 parent 168027b commit 9611253

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

stdlib/public/Concurrency/TaskGroup.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,16 @@
3939
#include <mutex>
4040
#endif
4141

42-
#if defined(__APPLE__)
43-
#include <asl.h>
44-
#include <unistd.h>
45-
#endif
46-
4742
#if SWIFT_STDLIB_HAS_ASL
4843
#include <asl.h>
4944
#elif defined(__ANDROID__)
5045
#include <android/log.h>
5146
#endif
5247

48+
#if __has_include(<unistd.h>)
49+
#include <unistd.h>
50+
#endif
51+
5352
#if defined(_WIN32)
5453
#include <io.h>
5554
#endif
@@ -573,10 +572,10 @@ struct TaskGroupStatus {
573572
#if defined(_WIN32)
574573
#define STDERR_FILENO 2
575574
_write(STDERR_FILENO, message, strlen(message));
576-
#else
575+
#elif defined(STDERR_FILENO)
577576
write(STDERR_FILENO, message, strlen(message));
578577
#endif
579-
#if defined(__APPLE__)
578+
#if defined(SWIFT_STDLIB_HAS_ASL)
580579
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", message);
581580
#elif defined(__ANDROID__)
582581
__android_log_print(ANDROID_LOG_FATAL, "SwiftRuntime", "%s", message);

0 commit comments

Comments
 (0)