Piotr Caban : msvcp90: Added macro to call functions from vtable.
Alexandre Julliard
julliard at winehq.org
Tue Dec 20 13:43:26 CST 2011
Module: wine
Branch: master
Commit: ddebdbf1e6580f5fbc1f4a954312e6e281df41af
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ddebdbf1e6580f5fbc1f4a954312e6e281df41af
Author: Piotr Caban <piotr at codeweavers.com>
Date: Tue Dec 20 15:56:42 2011 +0100
msvcp90: Added macro to call functions from vtable.
---
dlls/msvcp90/locale.c | 21 ++-------------------
dlls/msvcp90/msvcp90.h | 12 ++++++++++++
dlls/msvcp90/msvcp90_main.c | 14 ++++++++++++++
3 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c
index 16eda98..0c441c9 100644
--- a/dlls/msvcp90/locale.c
+++ b/dlls/msvcp90/locale.c
@@ -117,6 +117,8 @@ void __thiscall locale_facet_dtor(locale_facet *this)
}
DEFINE_THISCALL_WRAPPER(MSVCP_locale_facet_vector_dtor, 8)
+#define call_locale_facet_vector_dtor(this, flags) CALL_VTBL_FUNC(this, 0, \
+ locale_facet*, (locale_facet*, unsigned int), (this, flags))
locale_facet* __thiscall MSVCP_locale_facet_vector_dtor(locale_facet *this, unsigned int flags)
{
TRACE("(%p %x)\n", this, flags);
@@ -139,25 +141,6 @@ locale_facet* __thiscall MSVCP_locale_facet_vector_dtor(locale_facet *this, unsi
const vtable_ptr MSVCP_locale_facet_vtable[] = {
(vtable_ptr)THISCALL_NAME(MSVCP_locale_facet_vector_dtor)
};
-#ifdef __i386__
-static inline locale_facet* call_locale_facet_vector_dtor(locale_facet *this, unsigned int flags)
-{
- locale_facet *ret;
- void *dummy;
-
- __asm__ __volatile__ ("pushl %3\n\tcall *%2"
- : "=a" (ret), "=c" (dummy)
- : "r" (this->vtable[0]), "r" (flags), "1" (this)
- : "edx", "memory" );
- return ret;
-}
-#else
-static inline locale_facet* call_locale_facet_vector_dtor(locale_facet *this, unsigned int flags)
-{
- locale_facet * (__thiscall *dtor)(locale_facet *, unsigned int) = (void *)this->vtable[0];
- return dtor(this, flags);
-}
-#endif
/* ??0id at locale@std@@QAE at I@Z */
/* ??0id at locale@std@@QEAA at _K@Z */
diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h
index e906c6c..ee793b1 100644
--- a/dlls/msvcp90/msvcp90.h
+++ b/dlls/msvcp90/msvcp90.h
@@ -130,6 +130,18 @@ const rtti_object_locator name ## _rtti = { \
&name ## _hierarchy \
}
+#ifdef __i386__
+
+#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (WINAPI*)type)&vtbl_wrapper_##off)args
+
+extern void *vtbl_wrapper_0;
+
+#else
+
+#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (__cdecl***)type)this)[0][off/4]args
+
+#endif
+
/* exception object */
typedef void (*vtable_ptr)(void);
typedef struct __exception
diff --git a/dlls/msvcp90/msvcp90_main.c b/dlls/msvcp90/msvcp90_main.c
index 35fabfc..3aacf6d 100644
--- a/dlls/msvcp90/msvcp90_main.c
+++ b/dlls/msvcp90/msvcp90_main.c
@@ -28,6 +28,20 @@
WINE_DEFAULT_DEBUG_CHANNEL(msvcp90);
+#ifdef __i386__
+
+#define DEFINE_VTBL_WRAPPER(off) \
+ __ASM_GLOBAL_FUNC(vtbl_wrapper_ ## off, \
+ "popl %eax\n\t" \
+ "popl %ecx\n\t" \
+ "pushl %eax\n\t" \
+ "movl 0(%ecx), %eax\n\t" \
+ "jmp *" #off "(%eax)\n\t")
+
+DEFINE_VTBL_WRAPPER(0);
+
+#endif
+
void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
void (__cdecl *MSVCRT_operator_delete)(void*);
void* (__cdecl *MSVCRT_set_new_handler)(void*);
More information about the wine-cvs
mailing list