Skip to content

Commit 7c48b83

Browse files
committed
[Demangling] Use SWIFT_MEMORY_ORDER_CONSUME.
Also rearrange the #ifs to make the two pieces of code match more closely. rdar://91095592
1 parent 3f49b8b commit 7c48b83

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/Demangling/Errors.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
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.
5860
static 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

stdlib/public/runtime/Errors.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
#ifdef SWIFT_HAVE_CRASHREPORTERCLIENT
6161
#include <atomic>
6262
#include <malloc/malloc.h>
63+
64+
#include "swift/Runtime/Atomic.h"
6365
#endif // SWIFT_HAVE_CRASHREPORTERCLIENT
6466

6567
namespace FatalErrorFlags {
@@ -269,7 +271,7 @@ reportOnCrash(uint32_t flags, const char *message)
269271

270272
oldMessage = std::atomic_load_explicit(
271273
(volatile std::atomic<char *> *)&gCRAnnotations.message,
272-
std::memory_order_relaxed);
274+
SWIFT_MEMORY_ORDER_CONSUME);
273275

274276
do {
275277
if (newMessage) {
@@ -286,7 +288,7 @@ reportOnCrash(uint32_t flags, const char *message)
286288
(volatile std::atomic<char *> *)&gCRAnnotations.message,
287289
&oldMessage, newMessage,
288290
std::memory_order_release,
289-
std::memory_order_relaxed));
291+
SWIFT_MEMORY_ORDER_CONSUME));
290292
#else
291293
// empty
292294
#endif // SWIFT_HAVE_CRASHREPORTERCLIENT

0 commit comments

Comments
 (0)