[libcxx-commits] [PATCH] D73838: [libcxxabi] Fix layout of __cxa_exception for win64, fixing static assert failures
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Feb 1 13:11:19 PST 2020
mstorsjo created this revision.
mstorsjo added reviewers: steven_wu, rnk, rjmccall, EricWF, mclow.lists, ldionne.
Herald added subscribers: dexonsmith, christof.
Herald added a project: libc++.
mstorsjo edited the summary of this revision.
Win64 isn't LP64, it's LLP64, but there's no `__LLP64__` predefined - just check `_WIN64` in addition to `__LP64__`.
This fixes compilation after static asserts about the struct layout were added in f2a436058fcbc11291e73badb44e243f61046183 <https://reviews.llvm.org/rGf2a436058fcbc11291e73badb44e243f61046183>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73838
Files:
libcxxabi/src/cxa_exception.h
Index: libcxxabi/src/cxa_exception.h
===================================================================
--- libcxxabi/src/cxa_exception.h
+++ libcxxabi/src/cxa_exception.h
@@ -28,7 +28,7 @@
_LIBCXXABI_HIDDEN bool __isOurExceptionClass(const _Unwind_Exception*);
struct _LIBCXXABI_HIDDEN __cxa_exception {
-#if defined(__LP64__) || defined(_LIBCXXABI_ARM_EHABI)
+#if defined(__LP64__) || defined(_WIN64) || defined(_LIBCXXABI_ARM_EHABI)
// Now _Unwind_Exception is marked with __attribute__((aligned)),
// which implies __cxa_exception is also aligned. Insert padding
// in the beginning of the struct, rather than before unwindHeader.
@@ -62,7 +62,7 @@
void *adjustedPtr;
#endif
-#if !defined(__LP64__) && !defined(_LIBCXXABI_ARM_EHABI)
+#if !defined(__LP64__) && !defined(_WIN64) && !defined(_LIBCXXABI_ARM_EHABI)
// This is a new field to support C++ 0x exception_ptr.
// For binary compatibility it is placed where the compiler
// previously adding padded to 64-bit align unwindHeader.
@@ -75,7 +75,7 @@
// The layout of this structure MUST match the layout of __cxa_exception, with
// primaryException instead of referenceCount.
struct _LIBCXXABI_HIDDEN __cxa_dependent_exception {
-#if defined(__LP64__) || defined(_LIBCXXABI_ARM_EHABI)
+#if defined(__LP64__) || defined(_WIN64) || defined(_LIBCXXABI_ARM_EHABI)
void* reserve; // padding.
void* primaryException;
#endif
@@ -100,7 +100,7 @@
void *adjustedPtr;
#endif
-#if !defined(__LP64__) && !defined(_LIBCXXABI_ARM_EHABI)
+#if !defined(__LP64__) && !defined(_WIN64) && !defined(_LIBCXXABI_ARM_EHABI)
void* primaryException;
#endif
_Unwind_Exception unwindHeader;
@@ -125,7 +125,7 @@
sizeof(_Unwind_Exception) + sizeof(void*) ==
sizeof(__cxa_dependent_exception),
"propagationCount has wrong negative offset");
-#elif defined(__LP64__)
+#elif defined(__LP64__) || defined(_WIN64)
static_assert(offsetof(__cxa_exception, adjustedPtr) +
sizeof(_Unwind_Exception) + sizeof(void*) ==
sizeof(__cxa_exception),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73838.241897.patch
Type: text/x-patch
Size: 2141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200201/aac3f60b/attachment.bin>
More information about the libcxx-commits
mailing list