Skip to content

Commit ffb1cac

Browse files
authored
[Concurrency] Avoid using asl_log when not available (#41277)
1 parent e127690 commit ffb1cac

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#include <dispatch/dispatch.h>
5151
#endif
5252

53-
#if defined(__APPLE__)
53+
#if SWIFT_STDLIB_HAS_ASL
5454
#include <asl.h>
5555
#elif defined(__ANDROID__)
5656
#include <android/log.h>
@@ -60,12 +60,6 @@
6060
#include <unwind.h>
6161
#endif
6262

63-
#if defined(__APPLE__)
64-
#include <asl.h>
65-
#elif defined(__ANDROID__)
66-
#include <android/log.h>
67-
#endif
68-
6963
#if defined(__ELF__)
7064
#include <sys/syscall.h>
7165
#endif
@@ -399,9 +393,10 @@ void swift::swift_task_reportUnexpectedExecutor(
399393
#define STDERR_FILENO 2
400394
_write(STDERR_FILENO, message, strlen(message));
401395
#else
402-
write(STDERR_FILENO, message, strlen(message));
396+
fputs(message, stderr);
397+
fflush(stderr);
403398
#endif
404-
#if defined(__APPLE__)
399+
#if SWIFT_STDLIB_HAS_ASL
405400
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", message);
406401
#elif defined(__ANDROID__)
407402
__android_log_print(ANDROID_LOG_FATAL, "SwiftRuntime", "%s", message);

stdlib/public/Concurrency/TaskLocal.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "TaskPrivate.h"
2727
#include <set>
2828

29-
#if defined(__APPLE__)
29+
#if SWIFT_STDLIB_HAS_ASL
3030
#include <asl.h>
3131
#elif defined(__ANDROID__)
3232
#include <android/log.h>
@@ -299,9 +299,10 @@ static void swift_task_reportIllegalTaskLocalBindingWithinWithTaskGroupImpl(
299299
#define STDERR_FILENO 2
300300
_write(STDERR_FILENO, message, strlen(message));
301301
#else
302-
write(STDERR_FILENO, message, strlen(message));
302+
fputs(message, stderr);
303+
fflush(stderr);
303304
#endif
304-
#if defined(__APPLE__)
305+
#if SWIFT_STDLIB_HAS_ASL
305306
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", message);
306307
#elif defined(__ANDROID__)
307308
__android_log_print(ANDROID_LOG_FATAL, "SwiftRuntime", "%s", message);

0 commit comments

Comments
 (0)