diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-04-04 13:02:44 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-04-04 13:02:44 +0200 |
commit | b0515ea5fa6c29faebed616ae3e0213c72d24904 (patch) | |
tree | 3c83788fad2c1d1a6a806e6f2e70b0b9ceebe407 /bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx | |
parent | 13191ad7cd25871c08066817b6cc55b0d7ea419e (diff) |
Adapt cpp_uno/gcc3_linux_intel to GCC 4.7
...the same way cpp_uno/gcc3_linux_x86-64 was already adapted.
Diffstat (limited to 'bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx')
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx | 126 |
1 files changed, 4 insertions, 122 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx index 49bac6536021..64d401b0ecaa 100644 --- a/bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx @@ -30,7 +30,7 @@ #if defined (FREEBSD) || defined(NETBSD) || defined(OPENBSD) || defined(DRAGONFLY) #include <stdlib.h> #else -#include <malloc.h> +#include <alloca.h> #endif #include <com/sun/star/uno/genfunc.hxx> @@ -42,6 +42,7 @@ #include "bridges/cpp_uno/shared/unointerfaceproxy.hxx" #include "bridges/cpp_uno/shared/vtables.hxx" +#include "callvirtualmethod.hxx" #include "share.hxx" using namespace ::rtl; @@ -50,125 +51,6 @@ using namespace ::com::sun::star::uno; namespace { -//================================================================================================== -// The call instruction within the asm section of callVirtualMethod may throw -// exceptions. So that the compiler handles this correctly, it is important -// that (a) callVirtualMethod might call dummy_can_throw_anything (although this -// never happens at runtime), which in turn can throw exceptions, and (b) -// callVirtualMethod is not inlined at its call site (so that any exceptions are -// caught which are thrown from the instruction calling callVirtualMethod): -void callVirtualMethod( - void * pAdjustedThisPtr, - sal_Int32 nVtableIndex, - void * pRegisterReturn, - typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn, - sal_Int32 * pStackLongs, - sal_Int32 nStackLongs ) __attribute__((noinline)); - -void callVirtualMethod( - void * pAdjustedThisPtr, - sal_Int32 nVtableIndex, - void * pRegisterReturn, - typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn, - sal_Int32 * pStackLongs, - sal_Int32 nStackLongs ) -{ - // parameter list is mixed list of * and values - // reference parameters are pointers - - OSL_ENSURE( pStackLongs && pAdjustedThisPtr, "### null ptr!" ); - OSL_ENSURE( (sizeof(void *) == 4) && (sizeof(sal_Int32) == 4), "### unexpected size of int!" ); - OSL_ENSURE( nStackLongs && pStackLongs, "### no stack in callVirtualMethod !" ); - - // never called - if (! pAdjustedThisPtr) CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something - - volatile long edx = 0, eax = 0; // for register returns - void * stackptr; - asm volatile ( - "mov %%esp, %6\n\t" - // preserve potential 128bit stack alignment - "and $0xfffffff0, %%esp\n\t" - "mov %0, %%eax\n\t" - "lea -4(,%%eax,4), %%eax\n\t" - "and $0xf, %%eax\n\t" - "sub $0xc, %%eax\n\t" - "add %%eax, %%esp\n\t" - // copy values - "mov %0, %%eax\n\t" - "mov %%eax, %%edx\n\t" - "dec %%edx\n\t" - "shl $2, %%edx\n\t" - "add %1, %%edx\n" - "Lcopy:\n\t" - "pushl 0(%%edx)\n\t" - "sub $4, %%edx\n\t" - "dec %%eax\n\t" - "jne Lcopy\n\t" - // do the actual call - "mov %2, %%edx\n\t" - "mov 0(%%edx), %%edx\n\t" - "mov %3, %%eax\n\t" - "shl $2, %%eax\n\t" - "add %%eax, %%edx\n\t" - "mov 0(%%edx), %%edx\n\t" - "call *%%edx\n\t" - // save return registers - "mov %%eax, %4\n\t" - "mov %%edx, %5\n\t" - // cleanup stack - "mov %6, %%esp\n\t" - : - : "m"(nStackLongs), "m"(pStackLongs), "m"(pAdjustedThisPtr), - "m"(nVtableIndex), "m"(eax), "m"(edx), "m"(stackptr) - : "eax", "ecx", "edx" ); - switch( pReturnTypeDescr->eTypeClass ) - { - case typelib_TypeClass_VOID: - break; - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - ((long*)pRegisterReturn)[1] = edx; - case typelib_TypeClass_LONG: - case typelib_TypeClass_UNSIGNED_LONG: - case typelib_TypeClass_CHAR: - case typelib_TypeClass_ENUM: - ((long*)pRegisterReturn)[0] = eax; - break; - case typelib_TypeClass_SHORT: - case typelib_TypeClass_UNSIGNED_SHORT: - *(unsigned short*)pRegisterReturn = eax; - break; - case typelib_TypeClass_BOOLEAN: - case typelib_TypeClass_BYTE: - *(unsigned char*)pRegisterReturn = eax; - break; - case typelib_TypeClass_FLOAT: - asm ( "fstps %0" : : "m"(*(char *)pRegisterReturn) ); - break; - case typelib_TypeClass_DOUBLE: - asm ( "fstpl %0\n\t" : : "m"(*(char *)pRegisterReturn) ); - break; - default: - { -#if defined (FREEBSD) || defined(NETBSD) || defined(OPENBSD) || defined(MACOSX) || \ - defined(DRAGONFLY) - sal_Int32 const nRetSize = pReturnTypeDescr->nSize; - if (bSimpleReturn && nRetSize <= 8 && nRetSize > 0) - { - if (nRetSize > 4) - static_cast<long *>(pRegisterReturn)[1] = edx; - static_cast<long *>(pRegisterReturn)[0] = eax; - } -#else - (void)bSimpleReturn; -#endif - break; - } - } -} - -//================================================================================================== static void cpp_call( bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, bridges::cpp_uno::shared::VtableSlot aVtableSlot, @@ -287,7 +169,7 @@ static void cpp_call( try { OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic)" ); - callVirtualMethod( + CPPU_CURRENT_NAMESPACE::callVirtualMethod( pAdjustedThisPtr, aVtableSlot.index, pCppReturn, pReturnTypeDescr, bSimpleReturn, (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) ); @@ -330,7 +212,7 @@ static void cpp_call( catch (...) { // fill uno exception - fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); + fillUnoException( __cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); // temporary params for ( ; nTempIndizes--; ) |