From c4989e147f02f0c39e3cdaa9be4223d4fa4b438a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 6 Oct 2009 15:00:30 +0000 Subject: #i105302# allow build with -mfloat-abi=softfp -mfpu=vfp --- bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'bridges/source/cpp_uno') diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx index b365bdb8aee1..f59a16b2ac38 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx @@ -45,7 +45,17 @@ #include #include -#if defined(__ARM_EABI__) && !defined(__SOFTFP__) +/* + * Based on http://gcc.gnu.org/PR41443 + * References to __SOFTFP__ are incorrect for EABI; the __SOFTFP__ code + * should be used for *soft-float ABI* whether or not VFP is enabled, + * and __SOFTFP__ does specifically mean soft-float not soft-float ABI. + * + * Changing the conditionals to __SOFTFP__ || __ARM_EABI__ then + * -mfloat-abi=softfp should work. -mfloat-abi=hard won't; that would + * need both a new macro to identify the hard-VFP ABI. + */ +#if !defined(__ARM_EABI__) && !defined(__SOFTFP__) #error Not Implemented /* @@ -103,7 +113,7 @@ namespace arm void MapReturn(long r0, long r1, typelib_TypeClass eReturnType, void *pRegisterReturn) { -#ifndef __SOFTFP__ +#if !defined(__ARM_EABI__) && !defined(__SOFTFP__) register float fret asm("f0"); register double dret asm("f0"); #endif @@ -128,14 +138,14 @@ void MapReturn(long r0, long r1, typelib_TypeClass eReturnType, void *pRegisterR *(unsigned char*)pRegisterReturn = (unsigned char)r0; break; case typelib_TypeClass_FLOAT: -#ifdef __SOFTFP__ +#if defined(__ARM_EABI__) || defined(__SOFTFP__) ((long*)pRegisterReturn)[0] = r0; #else *(float*)pRegisterReturn = fret; #endif break; case typelib_TypeClass_DOUBLE: -#ifdef __SOFTFP__ +#if defined(__ARM_EABI__) || defined(__SOFTFP__) ((long*)pRegisterReturn)[1] = r1; ((long*)pRegisterReturn)[0] = r0; #else -- cgit From 8d4bb4276d78356cb15cf3d6d9c35eb3eb2ee3d1 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 6 Oct 2009 15:08:10 +0000 Subject: #i98028# SmallStruct and AllFloats --- bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx | 10 ++++----- bridges/source/cpp_uno/gcc3_linux_x86-64/abi.hxx | 2 +- bridges/source/cpp_uno/gcc3_linux_x86-64/call.s | 3 +++ .../source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx | 23 +------------------- .../source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx | 25 ++++++++++++++-------- 5 files changed, 25 insertions(+), 38 deletions(-) (limited to 'bridges/source/cpp_uno') diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx index 2aeaf9423859..ad0faa1a01aa 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx @@ -229,6 +229,7 @@ classify_argument( typelib_TypeDescriptionReference *pTypeRef, enum x86_64_reg_c for ( sal_Int32 nMember = 0; nMember < pStruct->nMembers; ++nMember ) { typelib_TypeDescriptionReference *pTypeInStruct = pStruct->ppTypeRefs[ nMember ]; + rByteOffset = pStruct->pMemberOffsets[ nMember ]; int num = classify_argument( pTypeInStruct, subclasses, rByteOffset ); @@ -243,9 +244,6 @@ classify_argument( typelib_TypeDescriptionReference *pTypeRef, enum x86_64_reg_c int pos = rByteOffset / 8; classes[i + pos] = merge_classes( subclasses[i], classes[i + pos] ); } - - if ( pTypeInStruct->eTypeClass != typelib_TypeClass_STRUCT ) - rByteOffset = pStruct->pMemberOffsets[ nMember ]; } TYPELIB_DANGER_RELEASE( pTypeDescr ); @@ -332,7 +330,7 @@ bool x86_64::return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef return examine_argument( pTypeRef, true, g, s ) == 0; } -void x86_64::fill_struct( typelib_TypeDescriptionReference *pTypeRef, void * const *pGPR, void * const *pSSE, void *pStruct ) +void x86_64::fill_struct( typelib_TypeDescriptionReference *pTypeRef, const sal_uInt64 *pGPR, const double *pSSE, void *pStruct ) { enum x86_64_reg_class classes[MAX_CLASSES]; int offset = 0; @@ -346,12 +344,12 @@ void x86_64::fill_struct( typelib_TypeDescriptionReference *pTypeRef, void * con { case X86_64_INTEGER_CLASS: case X86_64_INTEGERSI_CLASS: - *pStructAlign++ = *reinterpret_cast( *pGPR++ ); + *pStructAlign++ = *pGPR++; break; case X86_64_SSE_CLASS: case X86_64_SSESF_CLASS: case X86_64_SSEDF_CLASS: - *pStructAlign++ = *reinterpret_cast( *pSSE++ ); + *pStructAlign++ = *reinterpret_cast( pSSE++ ); break; default: break; diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.hxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.hxx index 5fffe680c28a..c5b7d94d2e01 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.hxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.hxx @@ -63,7 +63,7 @@ bool examine_argument( typelib_TypeDescriptionReference *pTypeRef, bool bInRetur */ bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef ); -void fill_struct( typelib_TypeDescriptionReference *pTypeRef, void * const *pGPR, void * const *pSSE, void *pStruct ); +void fill_struct( typelib_TypeDescriptionReference *pTypeRef, const sal_uInt64* pGPR, const double* pSSE, void *pStruct ); } // namespace x86_64 diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s b/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s index 736230705d5a..a0572ef61641 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s @@ -43,6 +43,9 @@ privateSnippetExecutor: je .Lfloat movq -144(%rbp), %rax # Return value (int case) + movq -136(%rbp), %rdx # Return value (int case) + movq -144(%rbp), %xmm0 # Return value (int case) + movq -136(%rbp), %xmm1 # Return value (int case) jmp .Lfinish .Lfloat: movlpd -144(%rbp), %xmm0 # Return value (float/double case) diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx index 5fb2bd7e12a3..d5d0425b7029 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx @@ -159,28 +159,7 @@ static typelib_TypeClass cpp2uno_call( else // struct <= 16 bytes || ptr to complex value || ref { void *pCppStack; - char pTmpStruct[16]; - - if ( bFitsRegisters && !rParam.bOut && - ( pParamTypeDescr->eTypeClass == typelib_TypeClass_STRUCT || - pParamTypeDescr->eTypeClass == typelib_TypeClass_EXCEPTION ) ) - { - if ( ( nr_gpr + nUsedGPR <= x86_64::MAX_GPR_REGS ) && ( nr_fpr + nUsedSSE <= x86_64::MAX_SSE_REGS ) ) - { - x86_64::fill_struct( rParam.pTypeRef, gpreg, fpreg, pTmpStruct ); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "nUsedGPR == %d, nUsedSSE == %d, pTmpStruct[0] == 0x%x, pTmpStruct[1] == 0x%x, **gpreg == 0x%lx\n", - nUsedGPR, nUsedSSE, pTmpStruct[0], pTmpStruct[1], *(sal_uInt64*)*gpreg ); -#endif - - pCppArgs[nPos] = pCppStack = reinterpret_cast( pTmpStruct ); - gpreg += nUsedGPR; - fpreg += nUsedSSE; - } - else - pCppArgs[nPos] = pCppStack = *ovrflw++; - } - else if ( nr_gpr < x86_64::MAX_GPR_REGS ) + if ( nr_gpr < x86_64::MAX_GPR_REGS ) { pCppArgs[nPos] = pCppStack = *gpreg++; nr_gpr++; diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx index 7199794409a8..23c40121afb7 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx @@ -53,13 +53,13 @@ using namespace ::com::sun::star::uno; //================================================================================================== static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, - void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn, + void * pRegisterReturn, typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn, sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, sal_uInt32 nGPR, double *pFPR, sal_uInt32 nFPR) __attribute__((noinline)); static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, - void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn, + void * pRegisterReturn, typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn, sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, sal_uInt32 nGPR, double *pFPR, sal_uInt32 nFPR) @@ -113,6 +113,7 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, sal_uInt64 rax; sal_uInt64 rdx; double xmm0; + double xmm1; asm volatile ( @@ -147,13 +148,14 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, "movq %%rax, %4\n\t" "movq %%rdx, %5\n\t" "movsd %%xmm0, %6\n\t" + "movsd %%xmm1, %7\n\t" : : "m" ( pMethod ), "m" ( pGPR ), "m" ( pFPR ), "m" ( nFPR ), - "m" ( rax ), "m" ( rdx ), "m" ( xmm0 ) + "m" ( rax ), "m" ( rdx ), "m" ( xmm0 ), "m" ( xmm1 ) : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r11" ); - switch (pReturnTypeDescr->eTypeClass) + switch (pReturnTypeRef->eTypeClass) { case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: @@ -179,12 +181,17 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, break; default: { - sal_Int32 const nRetSize = pReturnTypeDescr->nSize; + sal_Int32 const nRetSize = pReturnTypeRef->pType->nSize; if (bSimpleReturn && nRetSize <= 16 && nRetSize > 0) { - if (nRetSize > 8) - static_cast(pRegisterReturn)[1] = rdx; - static_cast(pRegisterReturn)[0] = rax; + sal_uInt64 longs[2]; + longs[0] = rax; + longs[1] = rdx; + + double doubles[2]; + doubles[0] = xmm0; + doubles[1] = xmm1; + x86_64::fill_struct( pReturnTypeRef, &longs[0], &doubles[0], pRegisterReturn); } break; } @@ -367,7 +374,7 @@ static void cpp_call( { callVirtualMethod( pAdjustedThisPtr, aVtableSlot.index, - pCppReturn, pReturnTypeDescr, bSimpleReturn, + pCppReturn, pReturnTypeRef, bSimpleReturn, pStackStart, ( pStack - pStackStart ), pGPR, nGPR, pFPR, nFPR ); -- cgit From acbe032eb0ffca6e7b159e90348a9b004d0924c5 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 6 Oct 2009 19:11:04 +0000 Subject: #i98028# fix warning after fixing SmallStruct and AllFloats --- bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bridges/source/cpp_uno') diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx index d5d0425b7029..c1e938446e77 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx @@ -126,7 +126,10 @@ static typelib_TypeClass cpp2uno_call( int nUsedGPR = 0; int nUsedSSE = 0; - bool bFitsRegisters = x86_64::examine_argument( rParam.pTypeRef, false, nUsedGPR, nUsedSSE ); +#if OSL_DEBUG_LEVEL > 1 + bool bFitsRegisters = +#endif + x86_64::examine_argument( rParam.pTypeRef, false, nUsedGPR, nUsedSSE ); if ( !rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ) ) // value { // Simple types must fit exactly one register on x86_64 -- cgit From bf9defceee8cef7a167dae7eed7f9b5a9c50a609 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 12 Oct 2009 13:29:25 +0000 Subject: #i105828# clear -Wp,-D_FORTIFY_SOURCE=2 warnings --- bridges/source/cpp_uno/shared/vtablefactory.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bridges/source/cpp_uno') diff --git a/bridges/source/cpp_uno/shared/vtablefactory.cxx b/bridges/source/cpp_uno/shared/vtablefactory.cxx index 34e5f9635974..3784f3959594 100644 --- a/bridges/source/cpp_uno/shared/vtablefactory.cxx +++ b/bridges/source/cpp_uno/shared/vtablefactory.cxx @@ -272,7 +272,7 @@ bool VtableFactory::createBlock(Block &block, sal_Int32 slotCount) const char *tmpfname = new char[aTmpName.getLength()+1]; strncpy(tmpfname, aTmpName.getStr(), aTmpName.getLength()+1); if ((block.fd = mkstemp(tmpfname)) == -1) - perror("creation of executable memory area failed"); + perror("creation of executable memory area failed"); if (block.fd == -1) { delete[] tmpfname; @@ -280,7 +280,13 @@ bool VtableFactory::createBlock(Block &block, sal_Int32 slotCount) const } unlink(tmpfname); delete[] tmpfname; - ftruncate(block.fd, block.size); + if (ftruncate(block.fd, block.size) == -1) + { + perror("truncation of executable memory area failed"); + close(block.fd); + block.fd = -1; + break; + } block.start = mmap(NULL, block.size, PROT_READ | PROT_WRITE, MAP_SHARED, block.fd, 0); if (block.start== MAP_FAILED) { block.start = 0; -- cgit From 62137f5e987904a0dab9cd7bec1e3320d00442a5 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 13 Oct 2009 12:54:28 +0000 Subject: #i105680# fix ia64 struct returning --- bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'bridges/source/cpp_uno') diff --git a/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx index 35b16d882632..d1d98f222738 100644 --- a/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx @@ -91,6 +91,31 @@ void MapReturn(const ia64::RegReturn &rRet, double dret, typelib_TypeDescription namespace ia64 { + bool is_complex_struct(const typelib_TypeDescription * type) + { + const typelib_CompoundTypeDescription * p + = reinterpret_cast< const typelib_CompoundTypeDescription * >(type); + for (sal_Int32 i = 0; i < p->nMembers; ++i) + { + if (p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_STRUCT || + p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_EXCEPTION) + { + typelib_TypeDescription * t = 0; + TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]); + bool b = is_complex_struct(t); + TYPELIB_DANGER_RELEASE(t); + if (b) { + return true; + } + } + else if (!bridges::cpp_uno::shared::isSimpleType(p->ppTypeRefs[i]->eTypeClass)) + return true; + } + if (p->pBaseTypeDescription != 0) + return is_complex_struct(&p->pBaseTypeDescription->aBase); + return false; + } + bool is_complex_struct( typelib_TypeDescriptionReference *pTypeRef ) { if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION) @@ -98,7 +123,7 @@ namespace ia64 typelib_TypeDescription * pTypeDescr = 0; TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); - bool bRet = bridges::cpp_uno::shared::relatesToInterfaceType( pTypeDescr ); + bool bRet = is_complex_struct( pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); return bRet; -- cgit