@@ -170,23 +170,32 @@ typedef void _MCF_tls_dtor(void* __ptr);
170
170
typedef void __MCF_cxa_dtor_cdecl (void * __arg);
171
171
172
172
#if defined __i386__ && (defined __GNUC__ || defined __clang__)
173
+ /* Support both calling conventions with a transparent union. */
173
174
typedef void __thiscall __MCF_cxa_dtor_thiscall (void * __arg);
174
175
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
177
179
union __attribute__ ((__transparent_union__)) __MCF_cxa_dtor_union
180
+ # endif
178
181
{
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 ;
181
184
182
185
# 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) { }
186
195
# endif
187
196
};
188
197
#else
189
- /* FIXME: MSVC doesn't seem to support `__thiscall` on non-member functions . */
198
+ /* Make these barely compile . */
190
199
typedef __MCF_cxa_dtor_cdecl __MCF_cxa_dtor_thiscall;
191
200
typedef __MCF_cxa_dtor_cdecl* __MCF_cxa_dtor_union;
192
201
#endif
0 commit comments