3636#if SWIFT_HAVE_CRASHREPORTERCLIENT
3737#include < atomic>
3838#include < malloc/malloc.h>
39+
40+ #include " swift/Runtime/Atomic.h"
41+
3942#include " CrashReporter.h"
4043#endif // SWIFT_HAVE_CRASHREPORTERCLIENT
4144
@@ -53,15 +56,15 @@ static int demangle_asprintf(char **strp, const char *format, ...);
5356
5457// -- Crash reporter integration ---------------------------------------------
5558
56- #if SWIFT_HAVE_CRASHREPORTERCLIENT
5759// Report a message to any forthcoming crash log.
5860static void reportOnCrash (uint32_t flags, const char *message) {
61+ #if SWIFT_HAVE_CRASHREPORTERCLIENT
5962 char *oldMessage = nullptr ;
6063 char *newMessage = nullptr ;
6164
6265 oldMessage = std::atomic_load_explicit (
6366 (volatile std::atomic<char *> *)&gCRAnnotations .message ,
64- std::memory_order_relaxed );
67+ SWIFT_MEMORY_ORDER_CONSUME );
6568
6669 do {
6770 if (newMessage) {
@@ -78,18 +81,14 @@ static void reportOnCrash(uint32_t flags, const char *message) {
7881 (volatile std::atomic<char *> *)&gCRAnnotations .message ,
7982 &oldMessage, newMessage,
8083 std::memory_order_release,
81- std::memory_order_relaxed ));
84+ SWIFT_MEMORY_ORDER_CONSUME ));
8285
8386 if (oldMessage && malloc_size (oldMessage))
8487 free (oldMessage);
85- }
86-
8788#else
88- static void
89- reportOnCrash (uint32_t flags, const char *message) {
9089 // empty
91- }
9290#endif // SWIFT_HAVE_CRASHREPORTERCLIENT
91+ }
9392
9493// -- Utility functions ------------------------------------------------------
9594
0 commit comments