Commit 373e4ea4 authored by Harris Hancock's avatar Harris Hancock

Return nullptr from MSVC PtmfHelper until ported

parent a8106dea
......@@ -255,12 +255,25 @@ class PtmfHelper {
friend struct GetFunctorStartAddress;
#if __GNUG__
void* ptr;
ptrdiff_t adj;
// Layout of a pointer-to-member-function used by GCC and compatible compilers.
void* apply(void* obj) {
#if defined(__arm__) || defined(__mips__) || defined(__aarch64__)
if (adj & 1) {
ptrdiff_t voff = (ptrdiff_t)ptr;
#else
#error "TODO(port): PTMF instruction address extraction"
ptrdiff_t voff = (ptrdiff_t)ptr;
if (voff & 1) {
voff &= ~1;
#endif
return *(void**)(*(char**)obj + voff);
} else {
return ptr;
}
}
#define BODY \
PtmfHelper result; \
......@@ -268,6 +281,15 @@ class PtmfHelper {
memcpy(&result, &p, sizeof(result)); \
return result
#else // __GNUG__
void* apply(void* obj) { return nullptr; }
// TODO(port): PTMF instruction address extraction
#define BODY return PtmfHelper{}
#endif // __GNUG__, else
template <typename R, typename C, typename... P, typename F>
static PtmfHelper from(F p) { BODY; }
// Create a PtmfHelper from some arbitrary pointer-to-member-function which is not
......@@ -284,21 +306,6 @@ class PtmfHelper {
// guess at P. Luckily, if the function parameters are template parameters then it's not
// necessary to be precise about P.
#undef BODY
void* apply(void* obj) {
#if defined(__arm__) || defined(__mips__) || defined(__aarch64__)
if (adj & 1) {
ptrdiff_t voff = (ptrdiff_t)ptr;
#else
ptrdiff_t voff = (ptrdiff_t)ptr;
if (voff & 1) {
voff &= ~1;
#endif
return *(void**)(*(char**)obj + voff);
} else {
return ptr;
}
}
};
template <typename... ParamTypes>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment