Skip to content

Commit 06e8d8d

Browse files
committed
fwd: Update __MCF_cxa_dtor_union
1 parent 743c4f4 commit 06e8d8d

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

mcfgthread/fwd.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,32 @@ typedef void _MCF_tls_dtor(void* __ptr);
170170
typedef void __MCF_cxa_dtor_cdecl(void* __arg);
171171

172172
#if defined __i386__ && (defined __GNUC__ || defined __clang__)
173+
/* Support both calling conventions with a transparent union. */
173174
typedef void __thiscall __MCF_cxa_dtor_thiscall(void* __arg);
174175
typedef union __MCF_cxa_dtor_union __MCF_cxa_dtor_union;
175-
176-
/* Provide dual-ABI support via this union. */
176+
# ifdef __cplusplus
177+
union __MCF_cxa_dtor_union
178+
# else
177179
union __attribute__((__transparent_union__)) __MCF_cxa_dtor_union
180+
# endif
178181
{
179-
__MCF_cxa_dtor_cdecl* __c_ptr;
180-
__MCF_cxa_dtor_thiscall* __tc_ptr;
182+
__MCF_cxa_dtor_cdecl* __cdecl_ptr;
183+
__MCF_cxa_dtor_thiscall* __thiscall_ptr;
181184

182185
# ifdef __cplusplus
183-
/* `__transparent_union__` is not supported in C++, so mimic it. */
184-
__MCF_cxa_dtor_union(__MCF_cxa_dtor_cdecl* __p) __MCF_NOEXCEPT : __c_ptr(__p) { }
185-
__MCF_cxa_dtor_union(__MCF_cxa_dtor_stdcall* __p) __MCF_NOEXCEPT : __tc_ptr(__p) { }
186+
/* Unfortunately, transparent unions are not supported in C++, and have
187+
* to be emulated with constructors. */
188+
__MCF_CXX11(constexpr)
189+
__MCF_cxa_dtor_union(__MCF_cxa_dtor_cdecl* __xptr) __MCF_NOEXCEPT
190+
: __cdecl_ptr(__xptr) { }
191+
192+
__MCF_CXX11(constexpr)
193+
__MCF_cxa_dtor_union(__MCF_cxa_dtor_thiscall* __xptr) __MCF_NOEXCEPT
194+
: __thiscall_ptr(__xptr) { }
186195
# endif
187196
};
188197
#else
189-
/* FIXME: MSVC doesn't seem to support `__thiscall` on non-member functions. */
198+
/* Make these barely compile. */
190199
typedef __MCF_cxa_dtor_cdecl __MCF_cxa_dtor_thiscall;
191200
typedef __MCF_cxa_dtor_cdecl* __MCF_cxa_dtor_union;
192201
#endif

0 commit comments

Comments
 (0)