Skip to content

Commit 8b04b7e

Browse files
committed
Add _LIBCXXABI_ASSERT since we can't use __verbose_abort from libc++abi (circular deps)
1 parent c841234 commit 8b04b7e

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

libcxxabi/src/abort_message.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@
1414
extern "C" _LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN void
1515
abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));
1616

17+
#define _LIBCXXABI_ASSERT(expr, msg) \
18+
do { \
19+
if (!(expr)) { \
20+
char const* __msg = (msg); \
21+
::abort_message("%s:%d: %s", __FILE__, __LINE__, __msg); \
22+
} \
23+
} while (false)
24+
1725
#endif

libcxxabi/src/cxa_demangle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// file does not yet support:
1111
// - C++ modules TS
1212

13-
#include <__assert>
14-
#define DEMANGLE_ASSERT(expr, msg) _LIBCPP_ASSERT_UNCATEGORIZED(expr, msg)
13+
#include "abort_message.h"
14+
#define DEMANGLE_ASSERT(expr, msg) _LIBCXXABI_ASSERT(expr, msg)
1515

1616
#include "demangle/DemangleConfig.h"
1717
#include "demangle/ItaniumDemangle.h"

libcxxabi/src/fallback_malloc.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "fallback_malloc.h"
10+
#include "abort_message.h"
1011

1112
#include <__threading_support>
1213
#ifndef _LIBCXXABI_HAS_NO_THREADS
@@ -142,7 +143,7 @@ void* fallback_malloc(size_t len) {
142143

143144
// Check the invariant that all heap_nodes pointers 'p' are aligned
144145
// so that 'p + 1' has an alignment of at least RequiredAlignment
145-
_LIBCPP_ASSERT_UNCATEGORIZED(reinterpret_cast<size_t>(p + 1) % RequiredAlignment == 0, "");
146+
_LIBCXXABI_ASSERT(reinterpret_cast<size_t>(p + 1) % RequiredAlignment == 0, "");
146147

147148
// Calculate the number of extra padding elements needed in order
148149
// to split 'p' and create a properly aligned heap_node from the tail
@@ -163,7 +164,7 @@ void* fallback_malloc(size_t len) {
163164
q->next_node = 0;
164165
q->len = static_cast<heap_size>(aligned_nelems);
165166
void* ptr = q + 1;
166-
_LIBCPP_ASSERT_UNCATEGORIZED(reinterpret_cast<size_t>(ptr) % RequiredAlignment == 0, "");
167+
_LIBCXXABI_ASSERT(reinterpret_cast<size_t>(ptr) % RequiredAlignment == 0, "");
167168
return ptr;
168169
}
169170

@@ -176,7 +177,7 @@ void* fallback_malloc(size_t len) {
176177
prev->next_node = p->next_node;
177178
p->next_node = 0;
178179
void* ptr = p + 1;
179-
_LIBCPP_ASSERT_UNCATEGORIZED(reinterpret_cast<size_t>(ptr) % RequiredAlignment == 0, "");
180+
_LIBCXXABI_ASSERT(reinterpret_cast<size_t>(ptr) % RequiredAlignment == 0, "");
180181
return ptr;
181182
}
182183
}

0 commit comments

Comments
 (0)