diff options
author | Peter Foley <pefoley2@verizon.net> | 2013-03-14 21:21:28 -0400 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-03-18 07:53:21 +0000 |
commit | a1fbebff263f65bc25c0c955da2e68e90cd2bb03 (patch) | |
tree | de1a32ca8c73f256364160a829b89143e8a041a0 /bridges/source | |
parent | f9f75ee3697f4fcbd94a4b005227860b9dd099f8 (diff) |
Cleanup bridges module
Reduce excessive copy-pasting
Remove bridges for C50 and C52 compilers which aren't in configure any
more
Prevent LTO from being used in the bridges module because it causes
crashes
Change-Id: I7ff85c2e8d6ff89c5acd48aea415e0960b3ef812
Reviewed-on: https://gerrit.libreoffice.org/2765
Reviewed-by: Tor Lillqvist <tml@iki.fi>
Tested-by: Tor Lillqvist <tml@iki.fi>
Diffstat (limited to 'bridges/source')
26 files changed, 0 insertions, 6489 deletions
diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/call.s b/bridges/source/cpp_uno/cc50_solaris_intel/call.s deleted file mode 100644 index a487491a82f1..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_intel/call.s +++ /dev/null @@ -1,266 +0,0 @@ -/ -/ This file is part of the LibreOffice project. -/ -/ This Source Code Form is subject to the terms of the Mozilla Public -/ License, v. 2.0. If a copy of the MPL was not distributed with this -/ file, You can obtain one at http://mozilla.org/MPL/2.0/. -/ -/ This file incorporates work covered by the following license notice: -/ -/ Licensed to the Apache Software Foundation (ASF) under one or more -/ contributor license agreements. See the NOTICE file distributed -/ with this work for additional information regarding copyright -/ ownership. The ASF licenses this file to you under the Apache -/ License, Version 2.0 (the "License"); you may not use this file -/ except in compliance with the License. You may obtain a copy of -/ the License at http://www.apache.org/licenses/LICENSE-2.0 . -/ - - .align 4 - .globl privateSnippetExecutorGeneral -privateSnippetExecutorGeneral: - movl %esp,%ecx - pushl %ebp / proper stack frame needed for exception handling - movl %esp,%ebp - andl $0xFFFFFFF8,%esp / align following 64bit arg - subl $0x8,%esp / 64bit nRegReturn - pushl %ecx / 32bit pCallStack - pushl %edx / 32bit nVtableOffset - pushl %eax / 32bit nFunctionIndex - call cpp_vtable_call - movl 12(%esp),%eax / 64 bit nRegReturn, lower half - leave - ret - .type privateSnippetExecutorGeneral, @function - .size privateSnippetExecutorGeneral, .-privateSnippetExecutorGeneral - - .align 4 - .globl privateSnippetExecutorVoid -privateSnippetExecutorVoid: - movl %esp,%ecx - pushl %ebp / proper stack frame needed for exception handling - movl %esp,%ebp - andl $0xFFFFFFF8,%esp / align following 64bit arg - subl $0x8,%esp / 64bit nRegReturn - pushl %ecx / 32bit pCallStack - pushl %edx / 32bit nVtableOffset - pushl %eax / 32bit nFunctionIndex - call cpp_vtable_call - leave - ret - .type privateSnippetExecutorVoid, @function - .size privateSnippetExecutorVoid, .-privateSnippetExecutorVoid - - .align 4 - .globl privateSnippetExecutorHyper -privateSnippetExecutorHyper: - movl %esp,%ecx - pushl %ebp / proper stack frame needed for exception handling - movl %esp,%ebp - andl $0xFFFFFFF8,%esp / align following 64bit arg - subl $0x8,%esp / 64bit nRegReturn - pushl %ecx / 32bit pCallStack - pushl %edx / 32bit nVtableOffset - pushl %eax / 32bit nFunctionIndex - call cpp_vtable_call - movl 12(%esp),%eax / 64 bit nRegReturn, lower half - movl 16(%esp),%edx / 64 bit nRegReturn, upper half - leave - ret - .type privateSnippetExecutorHyper, @function - .size privateSnippetExecutorHyper, .-privateSnippetExecutorHyper - - .align 4 - .globl privateSnippetExecutorFloat -privateSnippetExecutorFloat: - movl %esp,%ecx - pushl %ebp / proper stack frame needed for exception handling - movl %esp,%ebp - andl $0xFFFFFFF8,%esp / align following 64bit arg - subl $0x8,%esp / 64bit nRegReturn - pushl %ecx / 32bit pCallStack - pushl %edx / 32bit nVtableOffset - pushl %eax / 32bit nFunctionIndex - call cpp_vtable_call - flds 12(%esp) / 64 bit nRegReturn, lower half - leave - ret - .type privateSnippetExecutorFloat, @function - .size privateSnippetExecutorFloat, .-privateSnippetExecutorFloat - - .align 4 - .globl privateSnippetExecutorDouble -privateSnippetExecutorDouble: - movl %esp,%ecx - pushl %ebp / proper stack frame needed for exception handling - movl %esp,%ebp - andl $0xFFFFFFF8,%esp / align following 64bit arg - subl $0x8,%esp / 64bit nRegReturn - pushl %ecx / 32bit pCallStack - pushl %edx / 32bit nVtableOffset - pushl %eax / 32bit nFunctionIndex - call cpp_vtable_call - fldl 12(%esp) / 64 bit nRegReturn - leave - ret - .type privateSnippetExecutorDouble, @function - .size privateSnippetExecutorDouble, .-privateSnippetExecutorDouble - - .align 4 - .globl privateSnippetExecutorStruct -privateSnippetExecutorStruct: - movl %esp,%ecx - pushl %ebp / proper stack frame needed for exception handling - movl %esp,%ebp - andl $0xFFFFFFF8,%esp / align following 64bit arg - subl $0x8,%esp / 64bit nRegReturn - pushl %ecx / 32bit pCallStack - pushl %edx / 32bit nVtableOffset - pushl %eax / 32bit nFunctionIndex - call cpp_vtable_call - movl 12(%esp),%eax / 64 bit nRegReturn, lower half - leave - ret $4 - .type privateSnippetExecutorStruct, @function - .size privateSnippetExecutorStruct, .-privateSnippetExecutorStruct - - .align 4 - .globl callVirtualMethod -callVirtualMethod: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl %edx, -4(%ebp) - movl %ecx, -8(%ebp) - movl %eax, -12(%ebp) - movl %esp, -16(%ebp) - movl %ebx, -20(%ebp) - - / set ebx to GOT -.L_GOT_BEGIN_2: - call .L_GOT_END_2 -.L_GOT_END_2: - popl %ebx - addl $_GLOBAL_OFFSET_TABLE_+[.-.L_GOT_END_2],%ebx -.callBeginPosition: - movl 28(%ebp), %eax - movl %eax, %edx - dec %edx - shl $2, %edx - add 24(%ebp), %edx -.copyLong: - movl 0(%edx), %ecx - sub $4, %edx - push %ecx - dec %eax - jne .copyLong -.doCall: - movl 8(%ebp), %edx - movl 0(%edx), %edx - movl 12(%ebp), %eax - add $2, %eax - shl $2, %eax - add %eax, %edx - movl 0(%edx), %edx - - call *%edx - -.callVirtualMethodExceptionPosition: - / handle returns - movl 20(%ebp), %ecx - - / byte types - cmp $2, %ecx / typelib_TypeClass_BOOLEAN - je .handleByte - cmp $3, %ecx - je .handleByte / typelib_TypeClass_BYTE - - / half word types - cmp $4, %ecx / typelib_TypeClass_SHORT - je .handleShort - cmp $5, %ecx / typelib_TypeClass_UNSIGNED_SHORT - je .handleShort - - / word types - cmp $6, %ecx / typelib_TypeClass_LONG - je .handleWord - cmp $7, %ecx / typelib_TypeClass_UNSIGNED_LONG - je .handleWord - cmp $1, %ecx / typelib_TypeClass_CHAR (wchar_t) - je .handleWord - cmp $15, %ecx / typelib_TypeClass_ENUM - je .handleWord - - / double word types - cmp $8, %ecx / typelib_TypeClass_HYPER - je .handleDoubleWord - cmp $9, %ecx / typelib_TypeClass_UNSIGNED_HYPER - je .handleDoubleWord - - / float - cmp $10, %ecx / typelib_TypeClass_FLOAT - je .handleFloat - - / double - cmp $11, %ecx / typelib_TypeClass_DOUBLE - je .handleDouble - - / default: return void - jmp .doRestore -.handleByte: - movl 16(%ebp), %ecx - movb %al, 0(%ecx) - jmp .doRestore -.handleShort: - movl 16(%ebp), %ecx - movw %ax, 0(%ecx) - jmp .doRestore -.handleWord: - movl 16(%ebp), %ecx - movl %eax, 0(%ecx) - jmp .doRestore -.handleDoubleWord: - movl 16(%ebp), %ecx - movl %eax, 0(%ecx) - movl %edx, 4(%ecx) - jmp .doRestore -.handleFloat: - movl 16(%ebp), %ecx - fstps 0(%ecx) - jmp .doRestore -.handleDouble: - movl 16(%ebp), %ecx - fstpl 0(%ecx) - jmp .doRestore -.doRestore: - movl -4(%ebp), %edx - movl -8(%ebp), %ecx - movl -12(%ebp), %eax - movl -20(%ebp), %ebx - movl %ebp, %esp - popl %ebp - ret - .type callVirtualMethod, @function - .size callVirtualMethod, .-callVirtualMethod - - .globl callVirtualMethodExceptionHandler -callVirtualMethodExceptionHandler: - movl -4(%ebp), %edx - movl -8(%ebp), %ecx - movl -12(%ebp), %eax - movl -16(%ebp), %esp - movl -20(%ebp), %ebx - call __1cG__CrunMex_rethrow_q6F_v_@PLT - ret - - .type callVirtualMethodExceptionHandler, @function - .size callVirtualMethodExceptionHandler, .-callVirtualMethodExceptionHandler - - - .section .exception_ranges,"aw" - .align 4 - - .4byte .callBeginPosition@rel - .4byte .callVirtualMethodExceptionPosition-.callBeginPosition - .4byte callVirtualMethodExceptionHandler-.callBeginPosition - .zero 8 diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/cc50_solaris_intel.hxx b/bridges/source/cpp_uno/cc50_solaris_intel/cc50_solaris_intel.hxx deleted file mode 100644 index 53211b020f3b..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_intel/cc50_solaris_intel.hxx +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <cstddef> -#include <rtl/string.hxx> -#include <typeinfo> - -typedef struct _uno_Any uno_Any; -typedef struct _uno_Mapping uno_Mapping; - -// private C50 structures and functions -namespace __Crun -{ - struct static_type_info - { - std::ptrdiff_t m_pClassName; - int m_nSkip1; // must be 0 - void* m_pMagic; // points to some magic data - int m_nMagic[ 4 ]; - int m_nSkip2[2]; // must be 0 - }; - void* ex_alloc(unsigned); - void ex_throw( void*, const static_type_info*, void(*)(void*)); - void* ex_get(); - void ex_rethrow_q(); -} - -namespace __Cimpl -{ - const char* ex_name(); -} - -extern "C" void _ex_register( void*, int ); - -namespace CPPU_CURRENT_NAMESPACE -{ - -//################################################################################################## -//#### exceptions ################################################################################## -//################################################################################################## - -void cc50_solaris_intel_raiseException( - uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); - -void cc50_solaris_intel_fillUnoException( - void*, const char*, - uno_Any*, uno_Mapping * pCpp2Uno ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/cpp2uno.cxx b/bridges/source/cpp_uno/cc50_solaris_intel/cpp2uno.cxx deleted file mode 100644 index 7d2a0ea67ca3..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_intel/cpp2uno.cxx +++ /dev/null @@ -1,519 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <sal/alloca.h> - -#include <com/sun/star/uno/genfunc.hxx> -#include <uno/data.h> -#include <typelib/typedescription.hxx> - -#include "bridges/cpp_uno/shared/bridge.hxx" -#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx" -#include "bridges/cpp_uno/shared/types.hxx" -#include "bridges/cpp_uno/shared/vtablefactory.hxx" - -#include "cc50_solaris_intel.hxx" - -using namespace com::sun::star::uno; - -namespace -{ - -//================================================================================================== -void cpp2uno_call( - bridges::cpp_uno::shared::CppInterfaceProxy * pThis, - const typelib_TypeDescription * pMemberTypeDescr, - typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return - sal_Int32 nParams, typelib_MethodParameter * pParams, - void ** pCallStack, - sal_Int64 * pRegisterReturn /* space for register return */ ) -{ - // pCallStack: ret, [return ptr], this, params - char * pCppStack = (char *)(pCallStack +1); - - // return - typelib_TypeDescription * pReturnTypeDescr = 0; - if (pReturnTypeRef) - TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); - - void * pUnoReturn = 0; - void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need - - if (pReturnTypeDescr) - { - if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr )) - { - pUnoReturn = pRegisterReturn; // direct way for simple types - } - else // complex return via ptr (pCppReturn) - { - pCppReturn = *(void**)pCppStack; - pCppStack += sizeof( void* ); - pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( - pReturnTypeDescr ) - ? alloca( pReturnTypeDescr->nSize ) - : pCppReturn); // direct way - } - } - // pop this - pCppStack += sizeof( void* ); - - // stack space - OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" ); - // parameters - void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams ); - void ** pCppArgs = pUnoArgs + nParams; - // indizes of values this have to be converted (interface conversion cpp<=>uno) - sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams)); - // type descriptions for reconversions - typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams)); - - sal_Int32 nTempIndizes = 0; - - for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) - { - const typelib_MethodParameter & rParam = pParams[nPos]; - typelib_TypeDescription * pParamTypeDescr = 0; - TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); - - if (!rParam.bOut - && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) - // value - { - pCppArgs[ nPos ] = pUnoArgs[ nPos ] = pCppStack; - switch (pParamTypeDescr->eTypeClass) - { - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - case typelib_TypeClass_DOUBLE: - pCppStack += sizeof(sal_Int32); // extra long - } - // no longer needed - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - else // ptr to complex value | ref - { - pCppArgs[nPos] = *(void **)pCppStack; - - if (! rParam.bIn) // is pure out - { - // uno out is unconstructed mem! - pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ); - pTempIndizes[nTempIndizes] = nPos; - // will be released at reconversion - ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; - } - // is in/inout - else if (bridges::cpp_uno::shared::relatesToInterfaceType( - pParamTypeDescr )) - { - uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ), - *(void **)pCppStack, pParamTypeDescr, - pThis->getBridge()->getCpp2Uno() ); - pTempIndizes[nTempIndizes] = nPos; // has to be reconverted - // will be released at reconversion - ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; - } - else // direct way - { - pUnoArgs[nPos] = *(void **)pCppStack; - // no longer needed - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - } - pCppStack += sizeof(sal_Int32); // standard parameter length - } - - // ExceptionHolder - uno_Any aUnoExc; // Any will be constructed by callee - uno_Any * pUnoExc = &aUnoExc; - - // invoke uno dispatch call - (*pThis->getUnoI()->pDispatcher)( - pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc ); - - // in case no exception occurred... - if (pUnoExc) - { - // destruct temporary in/inout params - for ( ; nTempIndizes--; ) - { - sal_Int32 nIndex = pTempIndizes[nTempIndizes]; - - if (pParams[nIndex].bIn) // is in/inout => was constructed - uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], 0 ); - TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] ); - } - if (pReturnTypeDescr) - TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); - - CPPU_CURRENT_NAMESPACE::cc50_solaris_intel_raiseException( - &aUnoExc, pThis->getBridge()->getUno2Cpp() ); - // has to destruct the any - } - else // else no exception occurred... - { - // temporary params - for ( ; nTempIndizes--; ) - { - sal_Int32 nIndex = pTempIndizes[nTempIndizes]; - typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes]; - - if (pParams[nIndex].bOut) // inout/out - { - // convert and assign - uno_destructData( - pCppArgs[nIndex], pParamTypeDescr, - reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr, - pThis->getBridge()->getUno2Cpp() ); - } - // destroy temp uno param - uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); - - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - // return - if (pCppReturn) // has complex return - { - if (pUnoReturn != pCppReturn) // needs reconversion - { - uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr, - pThis->getBridge()->getUno2Cpp() ); - // destroy temp uno return - uno_destructData( pUnoReturn, pReturnTypeDescr, 0 ); - } - // complex return ptr is set to eax - *(void **)pRegisterReturn = pCppReturn; - } - if (pReturnTypeDescr) - { - TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); - } - } -} - - -//================================================================================================== -extern "C" void cpp_vtable_call( - int nFunctionIndex, int nVtableOffset, void** pCallStack, - sal_Int64 nRegReturn ) -{ - OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" ); - - // pCallStack: ret adr, [ret *], this, params - void * pThis; - if( nFunctionIndex & 0x80000000 ) - { - nFunctionIndex &= 0x7fffffff; - pThis = pCallStack[2]; - } - else - { - pThis = pCallStack[1]; - } - pThis = static_cast< char * >(pThis) - nVtableOffset; - bridges::cpp_uno::shared::CppInterfaceProxy * pCppI - = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy( - pThis); - - typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr(); - - OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, - "### illegal vtable index!" ); - if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex) - { - throw RuntimeException( "illegal vtable index!", (XInterface *)pThis ); - } - - // determine called method - sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex]; - OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" ); - - TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] ); - - switch (aMemberDescr.get()->eTypeClass) - { - case typelib_TypeClass_INTERFACE_ATTRIBUTE: - { - if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex) - { - // is GET method - cpp2uno_call( - pCppI, aMemberDescr.get(), - ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef, - 0, 0, // no params - pCallStack, &nRegReturn ); - } - else - { - // is SET method - typelib_MethodParameter aParam; - aParam.pTypeRef = - ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef; - aParam.bIn = sal_True; - aParam.bOut = sal_False; - - cpp2uno_call( - pCppI, aMemberDescr.get(), - 0, // indicates void return - 1, &aParam, - pCallStack, &nRegReturn ); - } - break; - } - case typelib_TypeClass_INTERFACE_METHOD: - { - // is METHOD - switch (nFunctionIndex) - { - // standard XInterface vtable calls - case 1: // acquire() - pCppI->acquireProxy(); // non virtual call! - break; - case 2: // release() - pCppI->releaseProxy(); // non virtual call! - break; - case 0: // queryInterface() opt - { - typelib_TypeDescription * pTD = 0; - TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pCallStack[3] )->getTypeLibType() ); - if (pTD) - { - XInterface * pInterface = 0; - (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)( - pCppI->getBridge()->getCppEnv(), - (void **)&pInterface, pCppI->getOid().pData, - (typelib_InterfaceTypeDescription *)pTD ); - - if (pInterface) - { - ::uno_any_construct( - reinterpret_cast< uno_Any * >( pCallStack[1] ), - &pInterface, pTD, - reinterpret_cast< uno_AcquireFunc >(cpp_acquire) ); - pInterface->release(); - TYPELIB_DANGER_RELEASE( pTD ); - *(void **)&nRegReturn = pCallStack[1]; - break; - } - TYPELIB_DANGER_RELEASE( pTD ); - } - } // else perform queryInterface() - default: - cpp2uno_call( - pCppI, aMemberDescr.get(), - ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef, - ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams, - ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams, - pCallStack, &nRegReturn ); - } - break; - } - default: - { - throw RuntimeException( "no member description found!", (XInterface *)pThis ); - } - } -} - -//================================================================================================== -bool isSimpleStruct(typelib_TypeDescriptionReference * type) { - typelib_TypeDescription * td = 0; - TYPELIB_DANGER_GET(&td, type); - OSL_ASSERT(td != 0); - for (typelib_CompoundTypeDescription * ctd - = reinterpret_cast< typelib_CompoundTypeDescription * >(td); - ctd != 0; ctd = ctd->pBaseTypeDescription) - { - OSL_ASSERT(ctd->aBase.eTypeClass == typelib_TypeClass_STRUCT); - for (sal_Int32 i = 0; i < ctd->nMembers; ++i) { - typelib_TypeClass c = ctd->ppTypeRefs[i]->eTypeClass; - switch (c) { - case typelib_TypeClass_STRING: - case typelib_TypeClass_TYPE: - case typelib_TypeClass_ANY: - case typelib_TypeClass_SEQUENCE: - case typelib_TypeClass_INTERFACE: - return false; - case typelib_TypeClass_STRUCT: - if (!isSimpleStruct(ctd->ppTypeRefs[i])) { - return false; - } - break; - default: - OSL_ASSERT( - c <= typelib_TypeClass_DOUBLE - || c == typelib_TypeClass_ENUM); - break; - } - } - } - TYPELIB_DANGER_RELEASE(td); - return true; -} - -extern "C" void privateSnippetExecutorGeneral(); -extern "C" void privateSnippetExecutorVoid(); -extern "C" void privateSnippetExecutorHyper(); -extern "C" void privateSnippetExecutorFloat(); -extern "C" void privateSnippetExecutorDouble(); -extern "C" void privateSnippetExecutorStruct(); -extern "C" typedef void (*PrivateSnippetExecutor)(); - -int const codeSnippetSize = 16; - -unsigned char * codeSnippet( - unsigned char * code, sal_Int32 functionIndex, sal_Int32 vtableOffset, - typelib_TypeDescriptionReference * returnType) -{ - typelib_TypeClass c = returnType == 0 - ? typelib_TypeClass_VOID : returnType->eTypeClass; - if (returnType != 0 && !bridges::cpp_uno::shared::isSimpleType(c)) { - functionIndex |= 0x80000000; - } - PrivateSnippetExecutor exec; - switch (c) { - case typelib_TypeClass_VOID: - exec = privateSnippetExecutorVoid; - break; - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - exec = privateSnippetExecutorHyper; - break; - case typelib_TypeClass_FLOAT: - exec = privateSnippetExecutorFloat; - break; - case typelib_TypeClass_DOUBLE: - exec = privateSnippetExecutorDouble; - break; - case typelib_TypeClass_STRUCT: - OSL_ASSERT(returnType != 0); - // For "simple" (more-or-less POD, but not exactly) structs, the caller - // pops the pointer to the return value off the stack, as documented in - // the Intel SYSV ABI; for other structs (which includes STRING, TYPE, - // ANY, sequences, and interfaces, btw.), the callee pops the pointer to - // the return value off the stack: - exec = isSimpleStruct(returnType) - ? privateSnippetExecutorStruct : privateSnippetExecutorGeneral; - break; - default: - exec = privateSnippetExecutorGeneral; - break; - } - unsigned char * p = code; - OSL_ASSERT(sizeof (sal_Int32) == 4); - // mov function_index, %eax: - *p++ = 0xB8; - *reinterpret_cast< sal_Int32 * >(p) = functionIndex; - p += sizeof (sal_Int32); - // mov vtable_offset, %edx: - *p++ = 0xBA; - *reinterpret_cast< sal_Int32 * >(p) = vtableOffset; - p += sizeof (sal_Int32); - // jmp privateSnippetExecutor: - *p++ = 0xE9; -#pragma disable_warn - void * e = reinterpret_cast< void * >(exec); -#pragma enable_warn - *reinterpret_cast< sal_Int32 * >(p) - = static_cast< unsigned char * >(e) - p - sizeof (sal_Int32); - p += sizeof (sal_Int32); - OSL_ASSERT(p - code <= codeSnippetSize); - return code + codeSnippetSize; -} - -} - -struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; }; - -bridges::cpp_uno::shared::VtableFactory::Slot * -bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block) { - return static_cast< Slot * >(block) + 1; -} - -sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize( - sal_Int32 slotCount) -{ - return (slotCount + 3) * sizeof (Slot) + slotCount * codeSnippetSize; -} - -bridges::cpp_uno::shared::VtableFactory::Slot * -bridges::cpp_uno::shared::VtableFactory::initializeBlock( - void * block, sal_Int32 slotCount) -{ - Slot * slots = mapBlockToVtable(block) + 2; - slots[-3].fn = 0; // RTTI - slots[-2].fn = 0; // null - slots[-1].fn = 0; // destructor - return slots + slotCount; -} - -unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( - Slot ** slots, unsigned char * code, - typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset, - sal_Int32 functionCount, sal_Int32 vtableOffset) -{ - (*slots) -= functionCount; - Slot * s = *slots; - for (sal_Int32 i = 0; i < type->nMembers; ++i) { - typelib_TypeDescription * member = 0; - TYPELIB_DANGER_GET(&member, type->ppMembers[i]); - OSL_ASSERT(member != 0); - switch (member->eTypeClass) { - case typelib_TypeClass_INTERFACE_ATTRIBUTE: - // Getter: - (s++)->fn = code; - code = codeSnippet( - code, functionOffset++, vtableOffset, - reinterpret_cast< typelib_InterfaceAttributeTypeDescription * >( - member)->pAttributeTypeRef); - // Setter: - if (!reinterpret_cast< - typelib_InterfaceAttributeTypeDescription * >( - member)->bReadOnly) - { - (s++)->fn = code; - code = codeSnippet(code, functionOffset++, vtableOffset, 0); - } - break; - - case typelib_TypeClass_INTERFACE_METHOD: - (s++)->fn = code; - code = codeSnippet( - code, functionOffset++, vtableOffset, - reinterpret_cast< typelib_InterfaceMethodTypeDescription * >( - member)->pReturnTypeRef); - break; - - default: - OSL_ASSERT(false); - break; - } - TYPELIB_DANGER_RELEASE(member); - } - return code; -} - -void bridges::cpp_uno::shared::VtableFactory::flushCode( - unsigned char const *, unsigned char const *) -{} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/except.cxx b/bridges/source/cpp_uno/cc50_solaris_intel/except.cxx deleted file mode 100644 index 7c9d61df6a5f..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_intel/except.cxx +++ /dev/null @@ -1,438 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <cstddef> -#include <dlfcn.h> -#include <new.h> -#include <typeinfo> -#include <list> -#include <map> -#include <rtl/alloc.h> -#include <osl/diagnose.h> - -#include <rtl/strbuf.hxx> -#include <typelib/typedescription.hxx> -#include <com/sun/star/uno/Any.hxx> - -#include "bridges/cpp_uno/shared/arraypointer.hxx" - -#include "cc50_solaris_intel.hxx" - -#include <hash.cxx> - -// need a += operator for OString and sal_Char - -{ - inline OString& operator+=( OString& rString, sal_Char cAdd ) - { - sal_Char add[2]; - add[0] = cAdd; - add[1] = 0; - return rString += add; - } -} - -using namespace std; -using namespace osl; -using namespace com::sun::star::uno; - -namespace CPPU_CURRENT_NAMESPACE -{ - -static OString toUNOname( const OString & rRTTIname ) -{ - OString aRet; - - const sal_Char* pRTTI = rRTTIname.getStr(); - const sal_Char* pOrg = pRTTI; - const sal_Char* pLast = pRTTI; - - while( 1 ) - { - if( *pRTTI == ':' || ! *pRTTI ) - { - if( !aRet.isEmpty() ) - aRet += "."; - aRet += rRTTIname.copy( pLast - pOrg, pRTTI - pLast ); - while( *pRTTI == ':' ) - pRTTI++; - pLast = pRTTI; - if( ! *pRTTI ) - break; - } - else - pRTTI++; - } - - return aRet; -} -//================================================================================================== -static OString toRTTIname( const OString & rUNOname ) -{ - OStringBuffer aRet( rUNOname.getLength()*2 ); - - sal_Int32 nIndex = 0; - do - { - if( nIndex > 0 ) - aRet.append( "::" ); - aRet.append( rUNOname.getToken( 0, '.', nIndex ) ); - } while( nIndex != -1 ); - - return aRet.makeStringAndClear(); -} -//================================================================================================== - -static OString toRTTImangledname( const OString & rRTTIname ) -{ - if( rRTTIname.isEmpty() ) - return OString(); - - OStringBuffer aRet( rRTTIname.getLength()*2 ); - - aRet.append( "__1n" ); - sal_Int32 nIndex = 0; - do - { - OString aToken( rRTTIname.getToken( 0, ':', nIndex ) ); - int nBytes = aToken.getLength(); - if( nBytes ) - { - if( nBytes > 25 ) - { - aRet.append( (sal_Char)( nBytes/26 + 'a' ) ); - aRet.append( (sal_Char)( nBytes%26 + 'A' ) ); - } - else - aRet.append( (sal_Char)( nBytes + 'A' ) ); - for (sal_Int32 i = 0; i < aToken.getLength(); ++i) { - char c = aToken[i]; - if (c == 'Q') { - aRet.append("QdD"); - } else { - aRet.append(c); - } - } - } - } while( nIndex != -1 ); - - aRet.append( '_' ); - - return aRet.makeStringAndClear(); -} - -//################################################################################################## -//#### RTTI simulation ############################################################################# -//################################################################################################## - -class RTTIHolder -{ - std::map< OString, void* > aAllRTTI; -public: - ~RTTIHolder(); - - void* getRTTI( const OString& rTypename ); - void* getRTTI_UnoName( const OString& rUnoTypename ) - { return getRTTI( toRTTIname( rUnoTypename ) ); } - - void* insertRTTI( const OString& rTypename ); - void* insertRTTI_UnoName( const OString& rTypename ) - { return insertRTTI( toRTTIname( rTypename ) ); } - void* generateRTTI( typelib_CompoundTypeDescription* pCompTypeDescr ); -}; - -RTTIHolder::~RTTIHolder() -{ - for ( std::map< OString, void* >::const_iterator iPos( aAllRTTI.begin() ); - iPos != aAllRTTI.end(); ++iPos ) - { - delete[] static_cast< char * >(iPos->second); - } -} - -#if OSL_DEBUG_LEVEL > 1 -#include <stdio.h> -#endif - -void* RTTIHolder::getRTTI( const OString& rTypename ) -{ - std::map< OString, void* >::iterator element; - - element = aAllRTTI.find( rTypename ); - if( element != aAllRTTI.end() ) - return (*element).second; - - // create rtti structure - element = aAllRTTI.find( rTypename ); - if( element != aAllRTTI.end() ) - return (*element).second; - - return NULL; -} - -static long nMagicId = 1; - -void* RTTIHolder::insertRTTI( const OString& rTypename ) -{ - OString aMangledName( toRTTImangledname( rTypename ) ); - NIST_Hash aHash( aMangledName.getStr(), aMangledName.getLength() ); - - - // rSuperTypename MUST exist !!! - std::size_t const RTTI_SIZE = 19; // 14??? - void** pRTTI = reinterpret_cast< void ** >( - new char[RTTI_SIZE * sizeof (void *) + strlen(rTypename.getStr()) + 1]); - pRTTI[ 0 ] = reinterpret_cast< void * >(RTTI_SIZE * sizeof (void *)); - pRTTI[ 1 ] = NULL; - pRTTI[ 2 ] = (void*)(7*sizeof(void*)); - pRTTI[ 3 ] = (void*)aHash.getHash()[0]; - pRTTI[ 4 ] = (void*)aHash.getHash()[1]; - pRTTI[ 5 ] = (void*)aHash.getHash()[2]; - pRTTI[ 6 ] = (void*)aHash.getHash()[3]; - pRTTI[ 7 ] = NULL; - pRTTI[ 8 ] = NULL; - - pRTTI[ 9 ] = pRTTI[ 3 ]; - pRTTI[ 10 ] = pRTTI[ 4 ]; - pRTTI[ 11 ] = pRTTI[ 5 ]; - pRTTI[ 12 ] = pRTTI[ 6 ]; - pRTTI[ 13 ] = (void*)0x80000000; - strcpy(reinterpret_cast< char * >(pRTTI + RTTI_SIZE), rTypename.getStr()); - - aAllRTTI[ rTypename ] = (void*)pRTTI; -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, - "generating base RTTI for type %s:\n" - " mangled: %s\n" - " hash: %.8x %.8x %.8x %.8x\n", - rTypename.getStr(), - aMangledName.getStr(), - pRTTI[ 3 ], pRTTI[ 4 ], pRTTI[ 5 ], pRTTI[ 6 ] - ); -#endif - return pRTTI; -} - -void* RTTIHolder::generateRTTI( typelib_CompoundTypeDescription * pCompTypeDescr ) -{ - OString aUNOCompTypeName( OUStringToOString( pCompTypeDescr->aBase.pTypeName, RTL_TEXTENCODING_ASCII_US ) ); - OString aRTTICompTypeName( toRTTIname( aUNOCompTypeName ) ); - - void* pHaveRTTI = getRTTI( aRTTICompTypeName ); - if( pHaveRTTI ) - return pHaveRTTI; - - if( ! pCompTypeDescr->pBaseTypeDescription ) - // this is a base type - return insertRTTI( aRTTICompTypeName ); - - // get base class RTTI - void* pSuperRTTI = generateRTTI( pCompTypeDescr->pBaseTypeDescription ); - OSL_ENSURE( pSuperRTTI, "could not generate RTTI for supertype !" ); - - // find out the size to allocate for RTTI - void** pInherit = (void**)((sal_uInt32)pSuperRTTI + ((sal_uInt32*)pSuperRTTI)[2] + 8); - int nInherit; - for( nInherit = 1; pInherit[ nInherit*5-1 ] != (void*)0x80000000; nInherit++ ) - ; - - OString aMangledName( toRTTImangledname( aRTTICompTypeName ) ); - NIST_Hash aHash( aMangledName.getStr(), aMangledName.getLength() ); - - std::size_t const rttiSize = 14 + nInherit * 5; - void** pRTTI = reinterpret_cast< void ** >( - new char[ - rttiSize * sizeof (void *) - + strlen(aRTTICompTypeName.getStr()) + 1]); - pRTTI[ 0 ] = reinterpret_cast< void * >(rttiSize * sizeof (void *)); - pRTTI[ 1 ] = NULL; - pRTTI[ 2 ] = (void*)(7*sizeof(void*)); - pRTTI[ 3 ] = (void*)aHash.getHash()[0]; - pRTTI[ 4 ] = (void*)aHash.getHash()[1]; - pRTTI[ 5 ] = (void*)aHash.getHash()[2]; - pRTTI[ 6 ] = (void*)aHash.getHash()[3]; - pRTTI[ 7 ] = NULL; - pRTTI[ 8 ] = NULL; - - memcpy( pRTTI+9, pInherit, 4*nInherit*5 ); - pRTTI[ 8 +nInherit*5 ] = NULL; - pRTTI[ 9 +nInherit*5 ] = pRTTI[ 3 ]; - pRTTI[ 10+nInherit*5 ] = pRTTI[ 4 ]; - pRTTI[ 11+nInherit*5 ] = pRTTI[ 5 ]; - pRTTI[ 12+nInherit*5 ] = pRTTI[ 6 ]; - pRTTI[ 13+nInherit*5 ] = (void*)0x80000000; - strcpy( - reinterpret_cast< char * >(pRTTI + rttiSize), - aRTTICompTypeName.getStr()); - - aAllRTTI[ aRTTICompTypeName ] = (void*)pRTTI; - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, - "generating struct RTTI for type %s:\n" - " mangled: %s\n" - " hash: %.8x %.8x %.8X %.8x\n", - aRTTICompTypeName.getStr(), - aMangledName.getStr(), - pRTTI[ 3 ], pRTTI[ 4 ], pRTTI[ 5 ], pRTTI[ 6 ] - ); -#endif - - return pRTTI; -} - -//__________________________________________________________________________________________________ - -static void deleteException( - void* pExc, unsigned char* thunk, typelib_TypeDescription* pType ) -{ - uno_destructData( - pExc, pType, reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - typelib_typedescription_release( pType ); - delete[] thunk; -} - -//__________________________________________________________________________________________________ - -//################################################################################################## -//#### exported #################################################################################### -//################################################################################################## - -void cc50_solaris_intel_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) -{ -#if OSL_DEBUG_LEVEL > 1 - OString cstr( - OUStringToOString( - *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ), - RTL_TEXTENCODING_ASCII_US ) ); - fprintf( stderr, "> uno exception occurred: %s\n", cstr.getStr() ); -#endif - bridges::cpp_uno::shared::ArrayPointer< unsigned char > thunkPtr( - new unsigned char[24]); - typelib_TypeDescription * pTypeDescr = 0; - // will be released by deleteException - typelib_typedescriptionreference_getDescription( &pTypeDescr, pUnoExc->pType ); - - void* pRTTI; - { - static ::osl::Mutex aMutex; - ::osl::Guard< ::osl::Mutex > guard( aMutex ); - - static RTTIHolder * s_pRTTI = 0; - if (! s_pRTTI) - { -#ifdef LEAK_STATIC_DATA - s_pRTTI = new RTTIHolder(); -#else - static RTTIHolder s_aRTTI; - s_pRTTI = &s_aRTTI; -#endif - } - - pRTTI = s_pRTTI->generateRTTI( (typelib_CompoundTypeDescription *)pTypeDescr ); - } - - // a must be - OSL_ENSURE( sizeof(sal_Int32) == sizeof(void *), "### pointer size differs from sal_Int32!" ); - - void * pCppExc = __Crun::ex_alloc( pTypeDescr->nSize ); - uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp ); - - // destruct uno exception - uno_any_destruct( pUnoExc, 0 ); - - unsigned char * thunk = thunkPtr.release(); - // movl %esp, %ecx: - thunk[0] = 0x8B; - thunk[1] = 0xCC; - // pushl pTypeDescr: - thunk[2] = 0x68; - *reinterpret_cast< void ** >(thunk + 3) = pTypeDescr; - // pushl thunk: - thunk[7] = 0x68; - *reinterpret_cast< void ** >(thunk + 8) = thunk; - // pushl 4(%ecx): - thunk[12] = 0xFF; - thunk[13] = 0x71; - thunk[14] = 0x04; - // call deleteException: - thunk[15] = 0xE8; -#pragma disable_warn - void * d = reinterpret_cast< void * >(deleteException); -#pragma enable_warn - *reinterpret_cast< std::ptrdiff_t * >(thunk + 16) = - static_cast< unsigned char * >(d) - (thunk + 20); - // addl $12, %esp: - thunk[20] = 0x83; - thunk[21] = 0xC4; - thunk[22] = 0x0C; - // ret: - thunk[23] = 0xC3; - -#pragma disable_warn - void (* f)(void *) = reinterpret_cast< void (*)(void *) >(thunk); -#pragma enable_warn - __Crun::ex_throw(pCppExc, (const __Crun::static_type_info*)pRTTI, f); -} - -void cc50_solaris_intel_fillUnoException( - void* pCppExc, - const char* pInfo, - uno_Any* pUnoExc, - uno_Mapping * pCpp2Uno ) -{ - OSL_ASSERT( pInfo != 0 ); - OString uno_name( toUNOname( pInfo ) ); - OUString aName( OStringToOUString( - uno_name, RTL_TEXTENCODING_ASCII_US ) ); - typelib_TypeDescription * pExcTypeDescr = 0; - typelib_typedescription_getByName( &pExcTypeDescr, aName.pData ); - - if (pExcTypeDescr == 0) // the thing that should not be - { - RuntimeException aRE( - "exception type not found: " + aName, - Reference< XInterface >() ); - Type const & rType = ::getCppuType( &aRE ); - uno_type_any_constructAndConvert( - pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno ); -#if OSL_DEBUG_LEVEL > 0 - OString cstr( OUStringToOString( - aRE.Message, RTL_TEXTENCODING_ASCII_US ) ); - OSL_FAIL( cstr.getStr() ); -#endif - return; - } - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "> c++ exception occurred: %s\n", - OUStringToOString( - pExcTypeDescr->pTypeName, - RTL_TEXTENCODING_ASCII_US ).getStr() ); -#endif - // construct uno exception any - uno_any_constructAndConvert( - pUnoExc, pCppExc, pExcTypeDescr, pCpp2Uno ); - typelib_typedescription_release( pExcTypeDescr ); -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/hash.cxx b/bridges/source/cpp_uno/cc50_solaris_intel/hash.cxx deleted file mode 100644 index fe012d9d96cb..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_intel/hash.cxx +++ /dev/null @@ -1,253 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - - -#ifndef TEST -#include <sal/types.h> -#else -typedef unsigned int sal_uInt32; -#endif - -#include <string.h> - -/* - * build a hash for a character buffer using the NIST algorithm - */ - -class NIST_Hash -{ - - // helper functions - sal_uInt32 f1( sal_uInt32 x, sal_uInt32 y, sal_uInt32 z ) - { - return z ^ ( x & ( y ^ z ) ); - } - - sal_uInt32 f2( sal_uInt32 x, sal_uInt32 y, sal_uInt32 z ) - { - return x ^ y ^ z; - } - - sal_uInt32 f3( sal_uInt32 x, sal_uInt32 y, sal_uInt32 z ) - { - return ( x & y ) + ( z & ( x ^ y ) ); - } - - sal_uInt32 rotl( sal_uInt32 nValue, sal_uInt32 nBits ) - { - return ( nValue << nBits ) | ( nValue >> (32-nBits) ); - } - - sal_uInt32 expand_nostore( sal_uInt32 index ) - { - return data[index&15] ^ data[(index-14)&15] ^ data[(index-8)&15] ^ data[(index-3)&15]; - } - - sal_uInt32 expand_store( sal_uInt32 index ) - { - return data[index&15] ^= data[(index-14)&15] ^ data[(index-8)&15] ^ data[(index-3)&15]; - } - - void subRound( sal_uInt32 a, sal_uInt32& b, sal_uInt32 c, sal_uInt32 d, sal_uInt32& e, sal_uInt32 constant, sal_uInt32 datum, sal_uInt32 nFunction ) - { - e += rotl(a,5); - switch( nFunction ) - { - case 1: e += f1( b, c, d );break; - case 2: - case 4: e += f2( b, c, d );break; - case 3: e += f3( b, c, d );break; - } - e += constant + datum; - b = rotl( b, 30 ); - } - - void transform(); - void final(); - - // data members - sal_uInt32 data[16]; - sal_uInt32 hashdata[5]; -public: - NIST_Hash( const char* pString, sal_uInt32 nLen ); - - sal_uInt32 *getHash() { return hashdata; } -}; - -void NIST_Hash::transform() -{ - // constants - const sal_uInt32 K2 = 0x5A827999; - const sal_uInt32 K3 = 0x6ED9EBA1; - const sal_uInt32 K5 = 0x8F1BBCDC; - const sal_uInt32 K10 = 0xCA62C1D6; - - sal_uInt32 a, b, c, d, e; - a = hashdata[0]; - b = hashdata[1]; - c = hashdata[2]; - d = hashdata[3]; - e = hashdata[4]; - - subRound( a, b, c, d, e, K2, data[ 0], 1 ); - subRound( e, a, b, c, d, K2, data[ 1], 1 ); - subRound( d, e, a, b, c, K2, data[ 2], 1 ); - subRound( c, d, e, a, b, K2, data[ 3], 1 ); - subRound( b, c, d, e, a, K2, data[ 4], 1 ); - subRound( a, b, c, d, e, K2, data[ 5], 1 ); - subRound( e, a, b, c, d, K2, data[ 6], 1 ); - subRound( d, e, a, b, c, K2, data[ 7], 1 ); - subRound( c, d, e, a, b, K2, data[ 8], 1 ); - subRound( b, c, d, e, a, K2, data[ 9], 1 ); - subRound( a, b, c, d, e, K2, data[10], 1 ); - subRound( e, a, b, c, d, K2, data[11], 1 ); - subRound( d, e, a, b, c, K2, data[12], 1 ); - subRound( c, d, e, a, b, K2, data[13], 1 ); - subRound( b, c, d, e, a, K2, data[14], 1 ); - subRound( a, b, c, d, e, K2, data[15], 1 ); - subRound( e, a, b, c, d, K2, expand_store( 16 ), 1 ); - subRound( d, e, a, b, c, K2, expand_store( 17 ), 1 ); - subRound( c, d, e, a, b, K2, expand_store( 18 ), 1 ); - subRound( b, c, d, e, a, K2, expand_store( 19 ), 1 ); - - subRound( a, b, c, d, e, K3, expand_store( 20 ), 2 ); - subRound( e, a, b, c, d, K3, expand_store( 21 ), 2 ); - subRound( d, e, a, b, c, K3, expand_store( 22 ), 2 ); - subRound( c, d, e, a, b, K3, expand_store( 23 ), 2 ); - subRound( b, c, d, e, a, K3, expand_store( 24 ), 2 ); - subRound( a, b, c, d, e, K3, expand_store( 25 ), 2 ); - subRound( e, a, b, c, d, K3, expand_store( 26 ), 2 ); - subRound( d, e, a, b, c, K3, expand_store( 27 ), 2 ); - subRound( c, d, e, a, b, K3, expand_store( 28 ), 2 ); - subRound( b, c, d, e, a, K3, expand_store( 29 ), 2 ); - subRound( a, b, c, d, e, K3, expand_store( 30 ), 2 ); - subRound( e, a, b, c, d, K3, expand_store( 31 ), 2 ); - subRound( d, e, a, b, c, K3, expand_store( 32 ), 2 ); - subRound( c, d, e, a, b, K3, expand_store( 33 ), 2 ); - subRound( b, c, d, e, a, K3, expand_store( 34 ), 2 ); - subRound( a, b, c, d, e, K3, expand_store( 35 ), 2 ); - subRound( e, a, b, c, d, K3, expand_store( 36 ), 2 ); - subRound( d, e, a, b, c, K3, expand_store( 37 ), 2 ); - subRound( c, d, e, a, b, K3, expand_store( 38 ), 2 ); - subRound( b, c, d, e, a, K3, expand_store( 39 ), 2 ); - - subRound( a, b, c, d, e, K5, expand_store( 40 ), 3 ); - subRound( e, a, b, c, d, K5, expand_store( 41 ), 3 ); - subRound( d, e, a, b, c, K5, expand_store( 42 ), 3 ); - subRound( c, d, e, a, b, K5, expand_store( 43 ), 3 ); - subRound( b, c, d, e, a, K5, expand_store( 44 ), 3 ); - subRound( a, b, c, d, e, K5, expand_store( 45 ), 3 ); - subRound( e, a, b, c, d, K5, expand_store( 46 ), 3 ); - subRound( d, e, a, b, c, K5, expand_store( 47 ), 3 ); - subRound( c, d, e, a, b, K5, expand_store( 48 ), 3 ); - subRound( b, c, d, e, a, K5, expand_store( 49 ), 3 ); - subRound( a, b, c, d, e, K5, expand_store( 50 ), 3 ); - subRound( e, a, b, c, d, K5, expand_store( 51 ), 3 ); - subRound( d, e, a, b, c, K5, expand_store( 52 ), 3 ); - subRound( c, d, e, a, b, K5, expand_store( 53 ), 3 ); - subRound( b, c, d, e, a, K5, expand_store( 54 ), 3 ); - subRound( a, b, c, d, e, K5, expand_store( 55 ), 3 ); - subRound( e, a, b, c, d, K5, expand_store( 56 ), 3 ); - subRound( d, e, a, b, c, K5, expand_store( 57 ), 3 ); - subRound( c, d, e, a, b, K5, expand_store( 58 ), 3 ); - subRound( b, c, d, e, a, K5, expand_store( 59 ), 3 ); - - subRound( a, b, c, d, e, K10, expand_store( 60 ), 4 ); - subRound( e, a, b, c, d, K10, expand_store( 61 ), 4 ); - subRound( d, e, a, b, c, K10, expand_store( 62 ), 4 ); - subRound( c, d, e, a, b, K10, expand_store( 63 ), 4 ); - subRound( b, c, d, e, a, K10, expand_store( 64 ), 4 ); - subRound( a, b, c, d, e, K10, expand_store( 65 ), 4 ); - subRound( e, a, b, c, d, K10, expand_store( 66 ), 4 ); - subRound( d, e, a, b, c, K10, expand_store( 67 ), 4 ); - subRound( c, d, e, a, b, K10, expand_store( 68 ), 4 ); - subRound( b, c, d, e, a, K10, expand_store( 69 ), 4 ); - subRound( a, b, c, d, e, K10, expand_store( 70 ), 4 ); - subRound( e, a, b, c, d, K10, expand_store( 71 ), 4 ); - subRound( d, e, a, b, c, K10, expand_store( 72 ), 4 ); - subRound( c, d, e, a, b, K10, expand_store( 73 ), 4 ); - subRound( b, c, d, e, a, K10, expand_store( 74 ), 4 ); - subRound( a, b, c, d, e, K10, expand_store( 75 ), 4 ); - subRound( e, a, b, c, d, K10, expand_store( 76 ), 4 ); - subRound( d, e, a, b, c, K10, expand_nostore( 77 ), 4 ); - subRound( c, d, e, a, b, K10, expand_nostore( 78 ), 4 ); - subRound( b, c, d, e, a, K10, expand_nostore( 79 ), 4 ); - - hashdata[0] += a; - hashdata[1] += b; - hashdata[2] += c; - hashdata[3] += d; - hashdata[4] += e; -} - -#define BLOCKSIZE sizeof( data ) - -NIST_Hash::NIST_Hash( const char* pString, sal_uInt32 nLen ) -{ - hashdata[0] = 0x67452301; - hashdata[1] = 0xefcdab89; - hashdata[2] = 0x98badcfe; - hashdata[3] = 0x10325476; - hashdata[4] = 0xc3d2e1f0; - - sal_uInt32 nBytes = nLen; - - while( nLen >= sizeof( data ) ) - { - memcpy( data, pString, sizeof( data ) ); - pString += sizeof( data ); - nLen -= sizeof( data ); - transform(); - } - memcpy( data, pString, nLen ); - ((char*)data)[nLen++] = 0x80; - if( nLen > sizeof( data ) - 8 ) - { - memset( ((char*)data)+nLen, 0, sizeof( data ) - nLen ); - transform(); - memset( data, 0, sizeof( data ) - 8 ); - } - else - memset( ((char*)data)+nLen, 0, sizeof( data ) - 8 - nLen ); - data[14] = 0; - data[15] = nBytes << 3; - transform(); -} - -#ifdef TEST -#include <stdio.h> -int main( int argc, const char** argv ) -{ - const char* pHash = argc < 2 ? argv[0] : argv[1]; - - NIST_Hash aHash( pHash, strlen( pHash ) ); - sal_uInt32* pBits = aHash.getHash(); - - printf( "text : %s\n" - "bits : 0x%.8x 0x%.8x 0x%.8x 0x%.8x 0x%.8x\n", - pHash, - pBits[0], pBits[1], pBits[2],pBits[3],pBits[4] - ); - return 0; -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/uno2cpp.cxx b/bridges/source/cpp_uno/cc50_solaris_intel/uno2cpp.cxx deleted file mode 100644 index 85a59654ebcf..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_intel/uno2cpp.cxx +++ /dev/null @@ -1,409 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <sal/alloca.h> - -#include <com/sun/star/uno/genfunc.hxx> -#include "com/sun/star/uno/RuntimeException.hpp" -#include <uno/data.h> - -#include "bridges/cpp_uno/shared/bridge.hxx" -#include "bridges/cpp_uno/shared/types.hxx" -#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx" -#include "bridges/cpp_uno/shared/vtables.hxx" - -#include "cc50_solaris_intel.hxx" - -using namespace com::sun::star::uno; - -namespace -{ - -extern "C" { - void callVirtualMethod( - void * pAdjustedThisPtr, - sal_Int32 nVtableIndex, - void * pRegisterReturn, - typelib_TypeClass eReturnType, - sal_Int32 * pStackLongs, - sal_Int32 nStackLongs - ); -} - -//================================================================================================== -static inline void cpp_call( - bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, - bridges::cpp_uno::shared::VtableSlot aVtableSlot, - typelib_TypeDescriptionReference * pReturnTypeRef, - sal_Int32 nParams, typelib_MethodParameter * pParams, - void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc ) -{ - // max space for: [complex ret ptr], values|ptr ... - char * pCppStack = (char *)alloca( ((nParams+3) * sizeof(sal_Int64)) ); - char * pCppStackStart = pCppStack; - - // return - typelib_TypeDescription * pReturnTypeDescr = 0; - TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); - OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" ); - - void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion - - void * pReturnSpace = 0; - - if (pReturnTypeDescr) - { - if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr )) - { - pCppReturn = pUnoReturn; // direct way for simple types - } - else - { - // complex return via ptr - pCppReturn = *(void **)pCppStack - = (bridges::cpp_uno::shared::relatesToInterfaceType( - pReturnTypeDescr ) - ? alloca( pReturnTypeDescr->nSize ) - : pUnoReturn); // direct way - pCppStack += sizeof(void *); - } - } - // push this - void * pAdjustedThisPtr = reinterpret_cast< void ** >(pThis->getCppI()) - + aVtableSlot.offset; - *(void**)pCppStack = pAdjustedThisPtr; - pCppStack += sizeof( void* ); - - const int nMaxParams = 32; - // args - void * args_buffer[3 * nMaxParams]; - void ** pCppArgs = (void **)(nParams > nMaxParams ? rtl_allocateMemory( 3 * sizeof(void *) * nParams ) : args_buffer); - // indizes of values this have to be converted (interface conversion cpp<=>uno) - sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams); - // type descriptions for reconversions - typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams)); - - sal_Int32 nTempIndizes = 0; - - const int nTempBufferSize = 256; - sal_Int32 nTempBufferPos = 0; - long params_buffer[nTempBufferSize]; - - for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) - { - const typelib_MethodParameter & rParam = pParams[nPos]; - typelib_TypeDescription * pParamTypeDescr = 0; - TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); - - if (!rParam.bOut - && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) - { - pCppArgs[ nPos ] = pCppStack; - uno_copyAndConvertData( pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr, - pThis->getBridge()->getUno2Cpp() ); - - switch (pParamTypeDescr->eTypeClass) - { - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - case typelib_TypeClass_DOUBLE: - pCppStack += sizeof(sal_Int32); // extra long - } - // no longer needed - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - else // ptr to complex value | ref - { - if (! rParam.bIn) // is pure out - { - // cpp out is constructed mem, uno out is not! - if (pParamTypeDescr->nSize > (sizeof(long) * (nTempBufferSize - nTempBufferPos))) - { - uno_constructData( - *(void **)pCppStack = pCppArgs[nPos] = rtl_allocateMemory( pParamTypeDescr->nSize ), - pParamTypeDescr ); - pTempIndizes[nTempIndizes] = nPos | 0x80000000; // default constructed for cpp call - } - else - { - uno_constructData( - *(void **)pCppStack = pCppArgs[nPos] = (params_buffer + nTempBufferPos), - pParamTypeDescr ); - pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call - nTempBufferPos += (pParamTypeDescr->nSize / sizeof(long)) +1; - } - // will be released at reconversion - ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; - } - // is in/inout - else if (bridges::cpp_uno::shared::relatesToInterfaceType( - pParamTypeDescr )) - { - if (pParamTypeDescr->nSize > (sizeof(long)*(nTempBufferSize - nTempBufferPos))) - { - uno_copyAndConvertData( - *(void **)pCppStack = pCppArgs[nPos] = rtl_allocateMemory( pParamTypeDescr->nSize ), - pUnoArgs[nPos], pParamTypeDescr, - pThis->getBridge()->getUno2Cpp() ); - pTempIndizes[nTempIndizes] = nPos | 0x80000000; // has to be reconverted - } - else - { - uno_copyAndConvertData( - *(void **)pCppStack = pCppArgs[nPos] = (params_buffer + nTempBufferPos), - pUnoArgs[nPos], pParamTypeDescr, - pThis->getBridge()->getUno2Cpp() ); - pTempIndizes[nTempIndizes] = nPos; // has to be reconverted - nTempBufferPos += (pParamTypeDescr->nSize / sizeof(long)) +1; - } - // will be released at reconversion - ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; - } - else // direct way - { - *(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos]; - // no longer needed - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - } - pCppStack += sizeof(sal_Int32); // standard parameter length - } - - try - { - int nStackLongs = (pCppStack - pCppStackStart)/sizeof(sal_Int32); - if( nStackLongs & 1 ) - // stack has to be 8 byte aligned - nStackLongs++; - - callVirtualMethod( - pAdjustedThisPtr, aVtableSlot.index, - pCppReturn, - pReturnTypeDescr->eTypeClass, - (sal_Int32 *)pCppStackStart, - nStackLongs - ); - - // NO exception occurred... - *ppUnoExc = 0; - - // reconvert temporary params - for ( ; nTempIndizes--; ) - { - sal_Int32 nIndex = pTempIndizes[nTempIndizes]; - sal_Bool bAllocated = (nIndex & 0x80000000) != 0; - nIndex &= 0x7fffffff; - typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes]; - - if (pParams[nIndex].bIn) - { - if (pParams[nIndex].bOut) // inout - { - uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value - uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, - pThis->getBridge()->getCpp2Uno() ); - } - } - else // pure out - { - uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, - pThis->getBridge()->getCpp2Uno() ); - } - // destroy temp cpp param => cpp: every param was constructed - uno_destructData( - pCppArgs[nIndex], pParamTypeDescr, - reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - - if (bAllocated) - rtl_freeMemory( pCppArgs[nIndex] ); - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - // return value - if (pCppReturn && pUnoReturn != pCppReturn) - { - uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr, - pThis->getBridge()->getCpp2Uno() ); - uno_destructData( - pCppReturn, pReturnTypeDescr, - reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - } - } - catch( ... ) - { - void* pExc = __Crun::ex_get(); - const char* pName = __Cimpl::ex_name(); - - // get exception - CPPU_CURRENT_NAMESPACE::cc50_solaris_intel_fillUnoException( - pExc, pName, *ppUnoExc, - pThis->getBridge()->getCpp2Uno()); - - // temporary params - for ( ; nTempIndizes--; ) - { - sal_Int32 nIndex = pTempIndizes[nTempIndizes]; - sal_Bool bAllocated = (nIndex & 0x80000000) != 0; - nIndex &= 0x7fffffff; - // destroy temp cpp param => cpp: every param was constructed - uno_destructData( - pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], - reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - if (bAllocated) - rtl_freeMemory( pCppArgs[nIndex] ); - TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] ); - } - // return type - if (pReturnTypeDescr) - TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); - } - - if (pCppArgs != (void **)args_buffer) - rtl_freeMemory( pCppArgs ); - if (pReturnSpace) - rtl_freeMemory( pReturnSpace ); -} - -} - -namespace bridges { namespace cpp_uno { namespace shared { - -void unoInterfaceProxyDispatch( - uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr, - void * pReturn, void * pArgs[], uno_Any ** ppException ) -{ - // is my surrogate - bridges::cpp_uno::shared::UnoInterfaceProxy * pThis - = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI); - typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr; - - switch (pMemberDescr->eTypeClass) - { - case typelib_TypeClass_INTERFACE_ATTRIBUTE: - { - VtableSlot aVtableSlot( - getVtableSlot( - reinterpret_cast< - typelib_InterfaceAttributeTypeDescription const * >( - pMemberDescr))); - if (pReturn) - { - // dependent dispatch - cpp_call( - pThis, aVtableSlot, - ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef, - 0, 0, // no params - pReturn, pArgs, ppException ); - } - else - { - // is SET - typelib_MethodParameter aParam; - aParam.pTypeRef = - ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef; - aParam.bIn = sal_True; - aParam.bOut = sal_False; - - typelib_TypeDescriptionReference * pReturnTypeRef = 0; - OUString aVoidName( "void" ); - typelib_typedescriptionreference_new( - &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData ); - - // dependent dispatch - aVtableSlot.index += 1; // get, then set method - cpp_call( - pThis, aVtableSlot, - pReturnTypeRef, - 1, &aParam, - pReturn, pArgs, ppException ); - - typelib_typedescriptionreference_release( pReturnTypeRef ); - } - - break; - } - case typelib_TypeClass_INTERFACE_METHOD: - { - VtableSlot aVtableSlot( - getVtableSlot( - reinterpret_cast< - typelib_InterfaceMethodTypeDescription const * >( - pMemberDescr))); - switch (aVtableSlot.index) - { - // standard calls - case 1: // acquire uno interface - (*pUnoI->acquire)( pUnoI ); - *ppException = 0; - break; - case 2: // release uno interface - (*pUnoI->release)( pUnoI ); - *ppException = 0; - break; - case 0: // queryInterface() opt - { - typelib_TypeDescription * pTD = 0; - TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() ); - if (pTD) - { - uno_Interface * pInterface = 0; - (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)( - pThis->pBridge->getUnoEnv(), - (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD ); - - if (pInterface) - { - ::uno_any_construct( - reinterpret_cast< uno_Any * >( pReturn ), - &pInterface, pTD, 0 ); - (*pInterface->release)( pInterface ); - TYPELIB_DANGER_RELEASE( pTD ); - *ppException = 0; - break; - } - TYPELIB_DANGER_RELEASE( pTD ); - } - } // else perform queryInterface() - default: - // dependent dispatch - cpp_call( - pThis, aVtableSlot, - ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef, - ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams, - ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams, - pReturn, pArgs, ppException ); - } - break; - } - default: - { - ::com::sun::star::uno::RuntimeException aExc( - "illegal member type description!", - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() ); - - Type const & rExcType = ::getCppuType( &aExc ); - // binary identical null reference - ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 ); - } - } -} - -} } } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/call.s b/bridges/source/cpp_uno/cc50_solaris_sparc/call.s deleted file mode 100644 index 3bbb5f6d265c..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_sparc/call.s +++ /dev/null @@ -1,217 +0,0 @@ -! -! This file is part of the LibreOffice project. -! -! This Source Code Form is subject to the terms of the Mozilla Public -! License, v. 2.0. If a copy of the MPL was not distributed with this -! file, You can obtain one at http://mozilla.org/MPL/2.0/. -! -! This file incorporates work covered by the following license notice: -! -! Licensed to the Apache Software Foundation (ASF) under one or more -! contributor license agreements. See the NOTICE file distributed -! with this work for additional information regarding copyright -! ownership. The ASF licenses this file to you under the Apache -! License, Version 2.0 (the "License"); you may not use this file -! except in compliance with the License. You may obtain a copy of -! the License at http://www.apache.org/licenses/LICENSE-2.0 . -! - -.global privateSnippetExecutor -.type privateSnippetExecutor,2 -privateSnippetExecutor: - ! save %sp, -96, %sp already done in code snippet - st %i0, [%fp+68] - st %i1, [%fp+72] - st %i2, [%fp+76] - st %i3, [%fp+80] - st %i4, [%fp+84] - st %i5, [%fp+88] - ! %o0: functionIndex, stored by code snippet - ! %o1: vtableOffset, stored by code snippet - call cpp_vtable_call - add %fp, 68, %o2 -.privateSnippetExecutorExceptionPosition: - subcc %o0, 11, %g0 - be .double - subcc %o0, 10, %g0 - be .float - ld [%fp+72], %i0 - ld [%fp+76], %i1 - ret - restore -.double: - ldd [%fp+72], %f0 - ret - restore -.float: - ld [%fp+72], %f0 - ret - restore -.size privateSnippetExecutor,(.-privateSnippetExecutor) -.align 8 - - -.global callVirtualMethod -.type callVirtualMethod,2 -callVirtualMethod: - ! allocate FIRST stack to have own local registers - sethi %hi(-96), %g1 - or %g1, %lo(-96), %g1 - subcc %g1, %o5, %g1 - subcc %g1, %o5, %g1 - subcc %g1, %o5, %g1 - subcc %g1, %o5, %g1 - save %sp, %g1, %sp - ! copy stack longs if necessary - subcc %i5, 6, %l5 - ble .copyRegisters - nop - - ! prepare source location - add %i4, 24, %l4 - - ! prepare real stack - add %sp, 92, %l3 - -.copyLong: - ld [%l4+0], %l0 - st %l0, [%l3] - add %l4, 4, %l4 - add %l3, 4, %l3 - deccc %l5 - bne .copyLong - nop -.copyRegisters: - mov %i5, %l5 - mov %i4, %l4 - - ld [%l4], %o0 - add %l4, 4, %l4 - deccc %l5 - ble .doCall - - ld [%l4], %o1 - add %l4, 4, %l4 - deccc %l5 - ble .doCall - - ld [%l4], %o2 - add %l4, 4, %l4 - deccc %l5 - ble .doCall - - ld [%l4], %o3 - add %l4, 4, %l4 - deccc %l5 - ble .doCall - - ld [%l4], %o4 - add %l4, 4, %l4 - deccc %l5 - ble .doCall - - ld [%l4], %o5 - add %l4, 4, %l4 - - ! prepare complex return pointer - st %i2, [%sp+64] -.doCall: - ! get virtual table entry - mov %i1, %l1 - add %l1, 2, %l1 - sll %l1, 2, %l1 - ld [%i0], %l3 - add %l3, %l1, %l1 - ld [%l1], %l0 - jmpl %l0,%o7 - nop -.callVirtualMethodExceptionPosition: - ! handle returns - - !byte types - subcc %i3, 2, %l3 ! typelib_TypeClass_BOOLEAN - be .handleByte - subcc %i3, 3, %l3 ! typelib_TypeClass_BYTE - be .handleByte - - ! half word types - subcc %i3, 4, %l3 ! typelib_TypeClass_SHORT - be .handleShort - subcc %i3, 5, %l3 ! typelib_TypeClass_UNSIGNED_SHORT - be .handleShort - subcc %i3, 1, %l3 ! typelib_TypeClass_CHAR (sal_Unicode==sal_uInt16) - be .handleShort - - ! word types - subcc %i3, 6, %l3 ! typelib_TypeClass_LONG - be .handleWord - subcc %i3, 7, %l3 ! typelib_TypeClass_UNSIGNED_LONG - be .handleWord - subcc %i3, 15, %l3 ! typelib_TypeClass_ENUM - be .handleWord - - ! double word types - subcc %i3, 8, %l3 ! typelib_TypeClass_HYPER - be .handleDoubleWord - subcc %i3, 9, %l3 ! typelib_TypeClass_UNSIGNED_HYPER - be .handleDoubleWord - - ! float - subcc %i3, 10, %l3 ! typelib_TypeClass_FLOAT - be .handleFloat - - ! double - subcc %i3, 11, %l3 ! typelib_TypeClass_DOUBLE - be .handleDouble - - ! default: return void - nop ! empty prefetch - ba .doRestore - nop -.handleByte: - stb %o0, [%i2] - ba .doRestore - nop -.handleShort: - sth %o0, [%i2] - ba .doRestore - nop -.handleWord: - st %o0, [%i2] - ba .doRestore - nop -.handleDoubleWord: - st %o0, [%i2] - st %o1, [%i2+4] - ba .doRestore - nop -.handleFloat: - st %f0, [%i2] - ba .doRestore - nop -.handleDouble: - std %f0, [%fp-8] - ldd [%fp-8], %o0 - st %o0, [%i2] - st %o1, [%i2+4] - ba .doRestore - nop -.doRestore: - ret - restore ! stack frame for own locals -.size callVirtualMethod,(.-callVirtualMethod) -.align 8 - -.rethrow_handler: - call __1cG__CrunMex_rethrow_q6F_v_ - nop - -.section ".exception_ranges",#alloc -.word %r_disp32(.privateSnippetExecutorExceptionPosition) -.word 0 -.word .rethrow_handler-.privateSnippetExecutorExceptionPosition -.word 0,0 -.word %r_disp32(.callVirtualMethodExceptionPosition) -.word 0 -.word .rethrow_handler-.callVirtualMethodExceptionPosition -.word 0,0 diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/cc50_solaris_sparc.hxx b/bridges/source/cpp_uno/cc50_solaris_sparc/cc50_solaris_sparc.hxx deleted file mode 100644 index c557e7a418cb..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_sparc/cc50_solaris_sparc.hxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <cstddef> -#include <rtl/string.hxx> -#include <typeinfo> - -typedef struct _uno_Any uno_Any; -typedef struct _uno_Mapping uno_Mapping; - -// private C50 structures and functions -namespace __Crun -{ - struct static_type_info - { - std::ptrdiff_t m_pClassName; - int m_nSkip1; // must be 0 - void* m_pMagic; // points to some magic data - int m_nMagic[ 4 ]; - int m_nSkip2[2]; // must be 0 - }; - void* ex_alloc(unsigned); - void ex_throw( void*, const static_type_info*, void(*)(void*)); - void* ex_get(); - void ex_rethrow_q() throw(); -} - -namespace __Cimpl -{ - const char* ex_name(); -} - -extern "C" void _ex_register( void*, int ); - -namespace CPPU_CURRENT_NAMESPACE -{ - -inline char* adjustPointer( char* pIn, typelib_TypeDescription* pType ) -{ - switch( pType->nSize ) - { - case 1: return pIn + 3; - case 2: return pIn + 2; - case 3: return pIn + 1; - // Huh ? perhaps a char[3] ? Though that would be a pointer - // well, we have it anyway for symmetry - } - return pIn; -} - -//################################################################################################## -//#### exceptions ################################################################################## -//################################################################################################## - -void cc50_solaris_sparc_raiseException( - uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); - -void cc50_solaris_sparc_fillUnoException( - void*, const char*, - uno_Any*, uno_Mapping * pCpp2Uno ); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/cpp2uno.cxx b/bridges/source/cpp_uno/cc50_solaris_sparc/cpp2uno.cxx deleted file mode 100644 index fb00833d64a3..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_sparc/cpp2uno.cxx +++ /dev/null @@ -1,506 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <sal/alloca.h> - -#include <com/sun/star/uno/genfunc.hxx> -#include <uno/data.h> -#include <typelib/typedescription.hxx> - -#include "bridges/cpp_uno/shared/bridge.hxx" -#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx" -#include "bridges/cpp_uno/shared/types.hxx" -#include "bridges/cpp_uno/shared/vtablefactory.hxx" - -#include "cc50_solaris_sparc.hxx" -#include "flushcode.hxx" - -using namespace com::sun::star::uno; - -namespace -{ - -//================================================================================================== -static typelib_TypeClass cpp2uno_call( - bridges::cpp_uno::shared::CppInterfaceProxy * pThis, - const typelib_TypeDescription * pMemberTypeDescr, - typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return - sal_Int32 nParams, typelib_MethodParameter * pParams, - void ** pCallStack, - sal_Int64 * pRegisterReturn /* space for register return */ ) -{ - // pCallStack: [return ptr], this, params - char * pCppStack = (char *)pCallStack; - - // return - typelib_TypeDescription * pReturnTypeDescr = 0; - if (pReturnTypeRef) - TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); - - void * pUnoReturn = 0; - void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need - - if (pReturnTypeDescr) - { - if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr )) - { - pUnoReturn = pRegisterReturn; // direct way for simple types - } - else // complex return via ptr (pCppReturn) - { - pCppReturn = *pCallStack; - pCppStack += sizeof( void* ); - pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( - pReturnTypeDescr ) - ? alloca( pReturnTypeDescr->nSize ) - : pCppReturn); // direct way - } - } - // pop this - pCppStack += sizeof( void* ); - - // stack space - OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" ); - // parameters - void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams ); - void ** pCppArgs = pUnoArgs + nParams; - // indizes of values this have to be converted (interface conversion cpp<=>uno) - sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams)); - // type descriptions for reconversions - typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams)); - - sal_Int32 nTempIndizes = 0; - - for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) - { - const typelib_MethodParameter & rParam = pParams[nPos]; - typelib_TypeDescription * pParamTypeDescr = 0; - TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); - - if (!rParam.bOut - && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) - // value - { - pCppArgs[ nPos ] = pUnoArgs[ nPos ] = - CPPU_CURRENT_NAMESPACE::adjustPointer( - pCppStack, pParamTypeDescr ); - switch (pParamTypeDescr->eTypeClass) - { - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - case typelib_TypeClass_DOUBLE: - pCppStack += sizeof(sal_Int32); // extra long - } - // no longer needed - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - else // ptr to complex value | ref - { - pCppArgs[nPos] = *(void **)pCppStack; - - if (! rParam.bIn) // is pure out - { - // uno out is unconstructed mem! - pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ); - pTempIndizes[nTempIndizes] = nPos; - // will be released at reconversion - ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; - } - // is in/inout - else if (bridges::cpp_uno::shared::relatesToInterfaceType( - pParamTypeDescr )) - { - uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ), - *(void **)pCppStack, pParamTypeDescr, - pThis->getBridge()->getCpp2Uno() ); - pTempIndizes[nTempIndizes] = nPos; // has to be reconverted - // will be released at reconversion - ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; - } - else // direct way - { - pUnoArgs[nPos] = *(void **)pCppStack; - // no longer needed - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - } - pCppStack += sizeof(sal_Int32); // standard parameter length - } - - // ExceptionHolder - uno_Any aUnoExc; // Any will be constructed by callee - uno_Any * pUnoExc = &aUnoExc; - - // invoke uno dispatch call - (*pThis->getUnoI()->pDispatcher)( - pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc ); - - // in case no exception occurred... - if (pUnoExc) - { - // destruct temporary in/inout params - for ( ; nTempIndizes--; ) - { - sal_Int32 nIndex = pTempIndizes[nTempIndizes]; - - if (pParams[nIndex].bIn) // is in/inout => was constructed - uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], 0 ); - TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] ); - } - if (pReturnTypeDescr) - TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); - - CPPU_CURRENT_NAMESPACE::cc50_solaris_sparc_raiseException( - &aUnoExc, pThis->getBridge()->getUno2Cpp() ); - // has to destruct the any - // is here for dummy - return typelib_TypeClass_VOID; - } - else // else no exception occurred... - { - // temporary params - for ( ; nTempIndizes--; ) - { - sal_Int32 nIndex = pTempIndizes[nTempIndizes]; - typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes]; - - if (pParams[nIndex].bOut) // inout/out - { - // convert and assign - uno_destructData( - pCppArgs[nIndex], pParamTypeDescr, - reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr, - pThis->getBridge()->getUno2Cpp() ); - } - // destroy temp uno param - uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); - - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - // return - if (pCppReturn) // has complex return - { - if (pUnoReturn != pCppReturn) // needs reconversion - { - uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr, - pThis->getBridge()->getUno2Cpp() ); - // destroy temp uno return - uno_destructData( pUnoReturn, pReturnTypeDescr, 0 ); - } - // complex return ptr is set to eax - *(void **)pRegisterReturn = pCppReturn; - } - if (pReturnTypeDescr) - { - typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass; - TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); - return eRet; - } - else - return typelib_TypeClass_VOID; - } -} - - -//================================================================================================== -static typelib_TypeClass cpp_mediate( - sal_Int32 nFunctionIndex, - sal_Int32 nVtableOffset, - void ** pCallStack, - sal_Int64 * pRegisterReturn /* space for register return */ ) -{ - OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" ); - - // pCallStack: this, params - void * pThis; - if( nFunctionIndex & 0x80000000 ) - { - nFunctionIndex &= 0x7fffffff; - pThis = pCallStack[1]; - } - else - { - pThis = pCallStack[0]; - } - pThis = static_cast< char * >(pThis) - nVtableOffset; - bridges::cpp_uno::shared::CppInterfaceProxy * pCppI - = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy( - pThis); - - typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr(); - - OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, - "### illegal vtable index!" ); - - // determine called method - sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex]; - OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" ); - - TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] ); - - typelib_TypeClass eRet; - switch (aMemberDescr.get()->eTypeClass) - { - case typelib_TypeClass_INTERFACE_ATTRIBUTE: - { - if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex) - { - // is GET method - eRet = cpp2uno_call( - pCppI, aMemberDescr.get(), - ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef, - 0, 0, // no params - pCallStack, pRegisterReturn ); - } - else - { - // is SET method - typelib_MethodParameter aParam; - aParam.pTypeRef = - ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef; - aParam.bIn = sal_True; - aParam.bOut = sal_False; - - eRet = cpp2uno_call( - pCppI, aMemberDescr.get(), - 0, // indicates void return - 1, &aParam, - pCallStack, pRegisterReturn ); - } - break; - } - case typelib_TypeClass_INTERFACE_METHOD: - { - // is METHOD - switch (nFunctionIndex) - { - // standard XInterface vtable calls - case 1: // acquire() - pCppI->acquireProxy(); // non virtual call! - eRet = typelib_TypeClass_VOID; - break; - case 2: // release() - pCppI->releaseProxy(); // non virtual call! - eRet = typelib_TypeClass_VOID; - break; - case 0: // queryInterface() opt - { - typelib_TypeDescription * pTD = 0; - TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pCallStack[2] )->getTypeLibType() ); - if (pTD) - { - XInterface * pInterface = 0; - (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)( - pCppI->getBridge()->getCppEnv(), - (void **)&pInterface, pCppI->getOid().pData, - (typelib_InterfaceTypeDescription *)pTD ); - - if (pInterface) - { - ::uno_any_construct( - reinterpret_cast< uno_Any * >( pCallStack[0] ), - &pInterface, pTD, - reinterpret_cast< uno_AcquireFunc >(cpp_acquire) ); - pInterface->release(); - TYPELIB_DANGER_RELEASE( pTD ); - *(void **)pRegisterReturn = pCallStack[0]; - eRet = typelib_TypeClass_ANY; - break; - } - TYPELIB_DANGER_RELEASE( pTD ); - } - } // else perform queryInterface() - default: - eRet = cpp2uno_call( - pCppI, aMemberDescr.get(), - ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef, - ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams, - ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams, - pCallStack, pRegisterReturn ); - } - break; - } - } - - return eRet; -} - -} - -//================================================================================================== -extern "C" int cpp_vtable_call( - int nFunctionIndex, int nVtableOffset, void** pCallStack ) -{ - sal_Int64 nRegReturn; - typelib_TypeClass aType = cpp_mediate( - nFunctionIndex, nVtableOffset, pCallStack, &nRegReturn ); - OSL_ASSERT( sizeof(void *) == sizeof(sal_Int32) ); - switch( aType ) - { - // move return value into register space - // (will be loaded by machine code snippet) - // Use pCallStack[1/2] instead of pCallStack[0/1], because the former is - // properly dword aligned: - case typelib_TypeClass_BOOLEAN: - case typelib_TypeClass_BYTE: - pCallStack[1] = (void*)*(char*)&nRegReturn; - break; - case typelib_TypeClass_CHAR: - case typelib_TypeClass_SHORT: - case typelib_TypeClass_UNSIGNED_SHORT: - pCallStack[1] = (void*)*(short*)&nRegReturn; - break; - case typelib_TypeClass_DOUBLE: - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - // move long to %i1 - pCallStack[2] = ((void **)&nRegReturn)[ 1 ]; - case typelib_TypeClass_FLOAT: - default: - // move long to %i0 - pCallStack[1] = ((void **)&nRegReturn)[ 0 ]; - break; - } - return aType; -} - -//================================================================================================== -namespace { - -extern "C" void privateSnippetExecutor(); - -int const codeSnippetSize = 7 * 4; - -unsigned char * codeSnippet( - unsigned char * code, sal_Int32 functionIndex, sal_Int32 vtableOffset, - bool simpleRetType) -{ - sal_uInt32 index = functionIndex; - if (!simpleRetType) { - index |= 0x80000000; - } - unsigned int * p = reinterpret_cast< unsigned int * >(code); - OSL_ASSERT(sizeof (unsigned int) == 4); - // save %sp, -96, %sp ! 92 byte minimal stack frame, + 4 byte dword align: - *p++ = 0x9DE3BFA0; - // sethi %hi(privateSnippetExecutor), %l0: - *p++ = 0x21000000 - | (reinterpret_cast< unsigned int >(privateSnippetExecutor) >> 10); - // sethi %hi(index), %o0: - *p++ = 0x11000000 | (index >> 10); - // or %o0, %lo(index), %o0: - *p++ = 0x90122000 | (index & 0x3FF); - // sethi %hi(vtableOffset), %o1: - *p++ = 0x13000000 | (vtableOffset >> 10); - // jmpl %l0, %lo(privateSnippetExecutor), %g0: - *p++ = 0x81C42000 - | (reinterpret_cast< unsigned int >(privateSnippetExecutor) & 0x3FF); - // or %o1, %lo(vtableOffset), %o1: - *p++ = 0x92126000 | (vtableOffset & 0x3FF); - OSL_ASSERT( - reinterpret_cast< unsigned char * >(p) - code <= codeSnippetSize); - return code + codeSnippetSize; -} - -} - -struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; }; - -bridges::cpp_uno::shared::VtableFactory::Slot * -bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block) -{ - return static_cast< Slot * >(block) + 1; -} - -sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize( - sal_Int32 slotCount) -{ - return (slotCount + 3) * sizeof (Slot) + slotCount * codeSnippetSize; -} - -bridges::cpp_uno::shared::VtableFactory::Slot * -bridges::cpp_uno::shared::VtableFactory::initializeBlock( - void * block, sal_Int32 slotCount) -{ - Slot * slots = mapBlockToVtable(block) + 2; - slots[-3].fn = 0; // RTTI - slots[-2].fn = 0; // null - slots[-1].fn = 0; // destructor - return slots + slotCount; -} - -unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( - Slot ** slots, unsigned char * code, - typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset, - sal_Int32 functionCount, sal_Int32 vtableOffset) -{ - (*slots) -= functionCount; - Slot * s = *slots; - for (sal_Int32 i = 0; i < type->nMembers; ++i) { - typelib_TypeDescription * member = 0; - TYPELIB_DANGER_GET(&member, type->ppMembers[i]); - OSL_ASSERT(member != 0); - switch (member->eTypeClass) { - case typelib_TypeClass_INTERFACE_ATTRIBUTE: - // Getter: - (s++)->fn = code; - code = codeSnippet( - code, functionOffset++, vtableOffset, - bridges::cpp_uno::shared::isSimpleType( - reinterpret_cast< - typelib_InterfaceAttributeTypeDescription * >( - member)->pAttributeTypeRef)); - // Setter: - if (!reinterpret_cast< - typelib_InterfaceAttributeTypeDescription * >( - member)->bReadOnly) - { - (s++)->fn = code; - code = codeSnippet(code, functionOffset++, vtableOffset, true); - } - break; - - case typelib_TypeClass_INTERFACE_METHOD: - (s++)->fn = code; - code = codeSnippet( - code, functionOffset++, vtableOffset, - bridges::cpp_uno::shared::isSimpleType( - reinterpret_cast< - typelib_InterfaceMethodTypeDescription * >( - member)->pReturnTypeRef)); - break; - - default: - OSL_ASSERT(false); - break; - } - TYPELIB_DANGER_RELEASE(member); - } - return code; -} - -void bridges::cpp_uno::shared::VtableFactory::flushCode( - unsigned char const * begin, unsigned char const * end) -{ - bridges::cpp_uno::cc50_solaris_sparc::flushCode(begin, end); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx b/bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx deleted file mode 100644 index 9beb24c4b657..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx +++ /dev/null @@ -1,434 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <cstddef> -#include <dlfcn.h> -#include <new.h> -#include <typeinfo> -#include <list> -#include <map> -#include <rtl/alloc.h> -#include <osl/diagnose.h> -#include <typelib/typedescription.hxx> -#include <com/sun/star/uno/Any.hxx> -#include "com/sun/star/uno/RuntimeException.hpp" - -#include "cc50_solaris_sparc.hxx" -#include "flushcode.hxx" -#include <rtl/strbuf.hxx> - -#include "bridges/cpp_uno/shared/arraypointer.hxx" - -#include <hash.cxx> - -// need a += operator for OString and sal_Char - -{ - inline OString& operator+=( OString& rString, sal_Char cAdd ) - { - sal_Char add[2]; - add[0] = cAdd; - add[1] = 0; - return rString += add; - } -} - -using namespace std; -using namespace osl; -using namespace com::sun::star::uno; - -namespace CPPU_CURRENT_NAMESPACE -{ - -//================================================================================================== -static OString toUNOname( const OString & rRTTIname ) -{ - OString aRet; - - const sal_Char* pRTTI = rRTTIname.getStr(); - const sal_Char* pOrg = pRTTI; - const sal_Char* pLast = pRTTI; - - while( 1 ) - { - if( *pRTTI == ':' || ! *pRTTI ) - { - if( !aRet.isEmpty() ) - aRet += "."; - aRet += rRTTIname.copy( pLast - pOrg, pRTTI - pLast ); - while( *pRTTI == ':' ) - pRTTI++; - pLast = pRTTI; - if( ! *pRTTI ) - break; - } - else - pRTTI++; - } - - return aRet; -} -//================================================================================================== -static OString toRTTIname( const OString & rUNOname ) -{ - OStringBuffer aRet( rUNOname.getLength()*2 ); - - sal_Int32 nIndex = 0; - do - { - if( nIndex > 0 ) - aRet.append( "::" ); - aRet.append( rUNOname.getToken( 0, '.', nIndex ) ); - } while( nIndex != -1 ); - - return aRet.makeStringAndClear(); -} -//================================================================================================== - -static OString toRTTImangledname( const OString & rRTTIname ) -{ - if( rRTTIname.isEmpty() ) - return OString(); - - OStringBuffer aRet( rRTTIname.getLength()*2 ); - - aRet.append( "__1n" ); - sal_Int32 nIndex = 0; - do - { - OString aToken( rRTTIname.getToken( 0, ':', nIndex ) ); - int nBytes = aToken.getLength(); - if( nBytes ) - { - if( nBytes > 25 ) - { - aRet.append( (sal_Char)( nBytes/26 + 'a' ) ); - aRet.append( (sal_Char)( nBytes%26 + 'A' ) ); - } - else - aRet.append( (sal_Char)( nBytes + 'A' ) ); - for (sal_Int32 i = 0; i < aToken.getLength(); ++i) { - char c = aToken[i]; - if (c == 'Q') { - aRet.append("QdD"); - } else { - aRet.append(c); - } - } - } - } while( nIndex != -1 ); - - aRet.append( '_' ); - - return aRet.makeStringAndClear(); -} - - -//################################################################################################## -//#### RTTI simulation ############################################################################# -//################################################################################################## - -class RTTIHolder -{ - std::map< OString, void* > aAllRTTI; -public: - ~RTTIHolder(); - - void* getRTTI( const OString& rTypename ); - void* getRTTI_UnoName( const OString& rUnoTypename ) - { return getRTTI( toRTTIname( rUnoTypename ) ); } - - void* insertRTTI( const OString& rTypename ); - void* insertRTTI_UnoName( const OString& rTypename ) - { return insertRTTI( toRTTIname( rTypename ) ); } - void* generateRTTI( typelib_CompoundTypeDescription* pCompTypeDescr ); -}; - -RTTIHolder::~RTTIHolder() -{ - for ( std::map< OString, void* >::const_iterator iPos( aAllRTTI.begin() ); - iPos != aAllRTTI.end(); ++iPos ) - { - delete[] static_cast< char * >(iPos->second); - } -} - -#if OSL_DEBUG_LEVEL > 1 -#include <stdio.h> -#endif - -void* RTTIHolder::getRTTI( const OString& rTypename ) -{ - std::map< OString, void* >::iterator element; - - element = aAllRTTI.find( rTypename ); - if( element != aAllRTTI.end() ) - return (*element).second; - - // create rtti structure - element = aAllRTTI.find( rTypename ); - if( element != aAllRTTI.end() ) - return (*element).second; - - return NULL; -} - -void* RTTIHolder::insertRTTI( const OString& rTypename ) -{ - OString aMangledName( toRTTImangledname( rTypename ) ); - NIST_Hash aHash( aMangledName.getStr(), aMangledName.getLength() ); - - std::size_t const RTTI_SIZE = 19; // 14??? - void** pRTTI = reinterpret_cast< void ** >( - new char[RTTI_SIZE * sizeof (void *) + strlen(rTypename.getStr()) + 1]); - pRTTI[ 0 ] = reinterpret_cast< void * >(RTTI_SIZE * sizeof (void *)); - pRTTI[ 1 ] = NULL; - pRTTI[ 2 ] = (void*)(7*sizeof(void*)); - pRTTI[ 3 ] = (void*)aHash.getHash()[0]; - pRTTI[ 4 ] = (void*)aHash.getHash()[1]; - pRTTI[ 5 ] = (void*)aHash.getHash()[2]; - pRTTI[ 6 ] = (void*)aHash.getHash()[3]; - pRTTI[ 7 ] = NULL; - pRTTI[ 8 ] = NULL; - - pRTTI[ 9 ] = pRTTI[ 3 ]; - pRTTI[ 10 ] = pRTTI[ 4 ]; - pRTTI[ 11 ] = pRTTI[ 5 ]; - pRTTI[ 12 ] = pRTTI[ 6 ]; - pRTTI[ 13 ] = (void*)0x80000000; - strcpy(reinterpret_cast< char * >(pRTTI + RTTI_SIZE), rTypename.getStr()); - - aAllRTTI[ rTypename ] = (void*)pRTTI; -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, - "generating base RTTI for type %s:\n" - " mangled: %s\n" - " hash: %.8x %.8x %.8x %.8x\n", - rTypename.getStr(), - aMangledName.getStr(), - pRTTI[ 3 ], pRTTI[ 4 ], pRTTI[ 5 ], pRTTI[ 6 ] - ); -#endif - return pRTTI; -} - -//-------------------------------------------------------------------------------------------------- - -void* RTTIHolder::generateRTTI( typelib_CompoundTypeDescription * pCompTypeDescr ) -{ - OString aUNOCompTypeName( OUStringToOString( pCompTypeDescr->aBase.pTypeName, RTL_TEXTENCODING_ASCII_US ) ); - OString aRTTICompTypeName( toRTTIname( aUNOCompTypeName ) ); - - void* pHaveRTTI = getRTTI( aRTTICompTypeName ); - if( pHaveRTTI ) - return pHaveRTTI; - - if( ! pCompTypeDescr->pBaseTypeDescription ) - // this is a base type - return insertRTTI( aRTTICompTypeName ); - - // get base class RTTI - void* pSuperRTTI = generateRTTI( pCompTypeDescr->pBaseTypeDescription ); - OSL_ENSURE( pSuperRTTI, "could not generate RTTI for supertype !" ); - - // find out the size to allocate for RTTI - void** pInherit = (void**)((sal_uInt32)pSuperRTTI + ((sal_uInt32*)pSuperRTTI)[2] + 8); - int nInherit; - for( nInherit = 1; pInherit[ nInherit*5-1 ] != (void*)0x80000000; nInherit++ ) - ; - - OString aMangledName( toRTTImangledname( aRTTICompTypeName ) ); - NIST_Hash aHash( aMangledName.getStr(), aMangledName.getLength() ); - - std::size_t const rttiSize = 14 + nInherit * 5; - void** pRTTI = reinterpret_cast< void ** >( - new char[ - rttiSize * sizeof (void *) - + strlen(aRTTICompTypeName.getStr()) + 1]); - pRTTI[ 0 ] = reinterpret_cast< void * >(rttiSize * sizeof (void *)); - pRTTI[ 1 ] = NULL; - pRTTI[ 2 ] = (void*)(7*sizeof(void*)); - pRTTI[ 3 ] = (void*)aHash.getHash()[0]; - pRTTI[ 4 ] = (void*)aHash.getHash()[1]; - pRTTI[ 5 ] = (void*)aHash.getHash()[2]; - pRTTI[ 6 ] = (void*)aHash.getHash()[3]; - pRTTI[ 7 ] = NULL; - pRTTI[ 8 ] = NULL; - - memcpy( pRTTI+9, pInherit, 4*nInherit*5 ); - pRTTI[ 8 +nInherit*5 ] = NULL; - pRTTI[ 9 +nInherit*5 ] = pRTTI[ 3 ]; - pRTTI[ 10+nInherit*5 ] = pRTTI[ 4 ]; - pRTTI[ 11+nInherit*5 ] = pRTTI[ 5 ]; - pRTTI[ 12+nInherit*5 ] = pRTTI[ 6 ]; - pRTTI[ 13+nInherit*5 ] = (void*)0x80000000; - strcpy( - reinterpret_cast< char * >(pRTTI + rttiSize), - aRTTICompTypeName.getStr()); - - aAllRTTI[ aRTTICompTypeName ] = (void*)pRTTI; - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, - "generating struct RTTI for type %s:\n" - " mangled: %s\n" - " hash: %.8x %.8x %.8X %.8x\n", - aRTTICompTypeName.getStr(), - aMangledName.getStr(), - pRTTI[ 3 ], pRTTI[ 4 ], pRTTI[ 5 ], pRTTI[ 6 ] - ); -#endif - - return pRTTI; -} - -//-------------------------------------------------------------------------------------------------- - -static void deleteException( - void* pExc, unsigned int* thunk, typelib_TypeDescription* pType ) -{ - uno_destructData( - pExc, pType, reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - typelib_typedescription_release( pType ); - delete[] thunk; -} - -//__________________________________________________________________________________________________ - -//################################################################################################## -//#### exported #################################################################################### -//################################################################################################## - -void cc50_solaris_sparc_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) -{ -#if OSL_DEBUG_LEVEL > 1 - OString cstr( - OUStringToOString( - *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ), - RTL_TEXTENCODING_ASCII_US ) ); - fprintf( stderr, "> uno exception occurred: %s\n", cstr.getStr() ); -#endif - bridges::cpp_uno::shared::ArrayPointer< unsigned int > thunkPtr( - new unsigned int[6]); - - typelib_TypeDescription * pTypeDescr = 0; - // will be released by deleteException - typelib_typedescriptionreference_getDescription( &pTypeDescr, pUnoExc->pType ); - - void* pRTTI; - { - static ::osl::Mutex aMutex; - ::osl::Guard< ::osl::Mutex > guard( aMutex ); - - static RTTIHolder * s_pRTTI = 0; - if (! s_pRTTI) - { -#ifdef LEAK_STATIC_DATA - s_pRTTI = new RTTIHolder(); -#else - static RTTIHolder s_aRTTI; - s_pRTTI = &s_aRTTI; -#endif - } - - pRTTI = s_pRTTI->generateRTTI( (typelib_CompoundTypeDescription *)pTypeDescr ); - } - - // a must be - OSL_ENSURE( sizeof(sal_Int32) == sizeof(void *), "### pointer size differs from sal_Int32!" ); - - void * pCppExc = __Crun::ex_alloc( pTypeDescr->nSize ); - uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp ); - - // destruct uno exception - uno_any_destruct( pUnoExc, 0 ); - - unsigned int * thunk = thunkPtr.release(); - // sethi %hi(thunk), %o1: - thunk[0] = 0x13000000 | (reinterpret_cast< unsigned int >(thunk) >> 10); - // or %o1, %lo(thunk), %o1: - thunk[1] = 0x92126000 | (reinterpret_cast< unsigned int >(thunk) & 0x3FF); - // sethi %hi(pTypeDescr), %o2: - thunk[2] = 0x15000000 - | (reinterpret_cast< unsigned int >(pTypeDescr) >> 10); - // sethi %hi(deleteException), %o3 - thunk[3] = 0x17000000 - | (reinterpret_cast< unsigned int >(deleteException) >> 10); - // jmpl %o3, %lo(deleteException), %g0 - thunk[4] = 0x81C2E000 - | (reinterpret_cast< unsigned int >(deleteException) & 0x3FF); - // or %o2, %lo(pTypeDescr), %o2: - thunk[5] = 0x9412A000 - | (reinterpret_cast< unsigned int >(pTypeDescr) & 0x3FF); - bridges::cpp_uno::cc50_solaris_sparc::flushCode(thunk, thunk + 6); - -#pragma disable_warn - void (* f)(void *) = reinterpret_cast< void (*)(void *) >(thunk); -#pragma enable_warn - __Crun::ex_throw(pCppExc, (const __Crun::static_type_info*)pRTTI, f); -} - -void cc50_solaris_sparc_fillUnoException( - void* pCppExc, - const char* pInfo, - uno_Any* pUnoExc, - uno_Mapping * pCpp2Uno ) -{ - OSL_ASSERT( pInfo != 0 ); - OString uno_name( toUNOname( pInfo ) ); - OUString aName( OStringToOUString( - uno_name, RTL_TEXTENCODING_ASCII_US ) ); - typelib_TypeDescription * pExcTypeDescr = 0; - typelib_typedescription_getByName( &pExcTypeDescr, aName.pData ); - - if (pExcTypeDescr == 0) // the thing that should not be - { - RuntimeException aRE( - "exception type not found: " + aName, - Reference< XInterface >() ); - Type const & rType = ::getCppuType( &aRE ); - uno_type_any_constructAndConvert( - pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno ); -#if OSL_DEBUG_LEVEL > 0 - OString cstr( OUStringToOString( - aRE.Message, RTL_TEXTENCODING_ASCII_US ) ); - OSL_FAIL( cstr.getStr() ); -#endif - return; - } - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "> c++ exception occurred: %s\n", - OUStringToOString( - pExcTypeDescr->pTypeName, - RTL_TEXTENCODING_ASCII_US ).getStr() ); -#endif - // construct uno exception any - uno_any_constructAndConvert( - pUnoExc, pCppExc, pExcTypeDescr, pCpp2Uno ); - typelib_typedescription_release( pExcTypeDescr ); -} - -} - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/flushcode.hxx b/bridges/source/cpp_uno/cc50_solaris_sparc/flushcode.hxx deleted file mode 100644 index 35943c98c1cb..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_sparc/flushcode.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC50_SOLARIS_SPARC_FLUSHCODE_HXX -#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC50_SOLARIS_SPARC_FLUSHCODE_HXX - -#include "sal/config.h" - -extern "C" void sync_instruction_memory(caddr_t addr, int len); // from libc - -namespace bridges { namespace cpp_uno { namespace cc50_solaris_sparc { - -/** - * Flush a region of memory into which code has been written dynamically. - */ -inline void flushCode(void const * begin, void const * end) { - sync_instruction_memory( - static_cast< caddr_t >(const_cast< void * >(begin)), - static_cast< char const * >(end) - static_cast< char const * >(begin)); -} - -} } } - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/hash.cxx b/bridges/source/cpp_uno/cc50_solaris_sparc/hash.cxx deleted file mode 100644 index 605398fd8d76..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_sparc/hash.cxx +++ /dev/null @@ -1,254 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - - - -#ifndef TEST -#include <sal/types.h> -#else -typedef unsigned int sal_uInt32; -#endif - -#include <string.h> - -/* - * build a hash for a character buffer using the NIST algorithm - */ - -class NIST_Hash -{ - - // helper functions - sal_uInt32 f1( sal_uInt32 x, sal_uInt32 y, sal_uInt32 z ) - { - return z ^ ( x & ( y ^ z ) ); - } - - sal_uInt32 f2( sal_uInt32 x, sal_uInt32 y, sal_uInt32 z ) - { - return x ^ y ^ z; - } - - sal_uInt32 f3( sal_uInt32 x, sal_uInt32 y, sal_uInt32 z ) - { - return ( x & y ) + ( z & ( x ^ y ) ); - } - - sal_uInt32 rotl( sal_uInt32 nValue, sal_uInt32 nBits ) - { - return ( nValue << nBits ) | ( nValue >> (32-nBits) ); - } - - sal_uInt32 expand_nostore( sal_uInt32 index ) - { - return data[index&15] ^ data[(index-14)&15] ^ data[(index-8)&15] ^ data[(index-3)&15]; - } - - sal_uInt32 expand_store( sal_uInt32 index ) - { - return data[index&15] ^= data[(index-14)&15] ^ data[(index-8)&15] ^ data[(index-3)&15]; - } - - void subRound( sal_uInt32 a, sal_uInt32& b, sal_uInt32 c, sal_uInt32 d, sal_uInt32& e, sal_uInt32 constant, sal_uInt32 datum, sal_uInt32 nFunction ) - { - e += rotl(a,5); - switch( nFunction ) - { - case 1: e += f1( b, c, d );break; - case 2: - case 4: e += f2( b, c, d );break; - case 3: e += f3( b, c, d );break; - } - e += constant + datum; - b = rotl( b, 30 ); - } - - void transform(); - void final(); - - // data members - sal_uInt32 data[16]; - sal_uInt32 hashdata[5]; -public: - NIST_Hash( const char* pString, sal_uInt32 nLen ); - - sal_uInt32 *getHash() { return hashdata; } -}; - -void NIST_Hash::transform() -{ - // constants - const sal_uInt32 K2 = 0x5A827999; - const sal_uInt32 K3 = 0x6ED9EBA1; - const sal_uInt32 K5 = 0x8F1BBCDC; - const sal_uInt32 K10 = 0xCA62C1D6; - - sal_uInt32 a, b, c, d, e; - a = hashdata[0]; - b = hashdata[1]; - c = hashdata[2]; - d = hashdata[3]; - e = hashdata[4]; - - subRound( a, b, c, d, e, K2, data[ 0], 1 ); - subRound( e, a, b, c, d, K2, data[ 1], 1 ); - subRound( d, e, a, b, c, K2, data[ 2], 1 ); - subRound( c, d, e, a, b, K2, data[ 3], 1 ); - subRound( b, c, d, e, a, K2, data[ 4], 1 ); - subRound( a, b, c, d, e, K2, data[ 5], 1 ); - subRound( e, a, b, c, d, K2, data[ 6], 1 ); - subRound( d, e, a, b, c, K2, data[ 7], 1 ); - subRound( c, d, e, a, b, K2, data[ 8], 1 ); - subRound( b, c, d, e, a, K2, data[ 9], 1 ); - subRound( a, b, c, d, e, K2, data[10], 1 ); - subRound( e, a, b, c, d, K2, data[11], 1 ); - subRound( d, e, a, b, c, K2, data[12], 1 ); - subRound( c, d, e, a, b, K2, data[13], 1 ); - subRound( b, c, d, e, a, K2, data[14], 1 ); - subRound( a, b, c, d, e, K2, data[15], 1 ); - subRound( e, a, b, c, d, K2, expand_store( 16 ), 1 ); - subRound( d, e, a, b, c, K2, expand_store( 17 ), 1 ); - subRound( c, d, e, a, b, K2, expand_store( 18 ), 1 ); - subRound( b, c, d, e, a, K2, expand_store( 19 ), 1 ); - - subRound( a, b, c, d, e, K3, expand_store( 20 ), 2 ); - subRound( e, a, b, c, d, K3, expand_store( 21 ), 2 ); - subRound( d, e, a, b, c, K3, expand_store( 22 ), 2 ); - subRound( c, d, e, a, b, K3, expand_store( 23 ), 2 ); - subRound( b, c, d, e, a, K3, expand_store( 24 ), 2 ); - subRound( a, b, c, d, e, K3, expand_store( 25 ), 2 ); - subRound( e, a, b, c, d, K3, expand_store( 26 ), 2 ); - subRound( d, e, a, b, c, K3, expand_store( 27 ), 2 ); - subRound( c, d, e, a, b, K3, expand_store( 28 ), 2 ); - subRound( b, c, d, e, a, K3, expand_store( 29 ), 2 ); - subRound( a, b, c, d, e, K3, expand_store( 30 ), 2 ); - subRound( e, a, b, c, d, K3, expand_store( 31 ), 2 ); - subRound( d, e, a, b, c, K3, expand_store( 32 ), 2 ); - subRound( c, d, e, a, b, K3, expand_store( 33 ), 2 ); - subRound( b, c, d, e, a, K3, expand_store( 34 ), 2 ); - subRound( a, b, c, d, e, K3, expand_store( 35 ), 2 ); - subRound( e, a, b, c, d, K3, expand_store( 36 ), 2 ); - subRound( d, e, a, b, c, K3, expand_store( 37 ), 2 ); - subRound( c, d, e, a, b, K3, expand_store( 38 ), 2 ); - subRound( b, c, d, e, a, K3, expand_store( 39 ), 2 ); - - subRound( a, b, c, d, e, K5, expand_store( 40 ), 3 ); - subRound( e, a, b, c, d, K5, expand_store( 41 ), 3 ); - subRound( d, e, a, b, c, K5, expand_store( 42 ), 3 ); - subRound( c, d, e, a, b, K5, expand_store( 43 ), 3 ); - subRound( b, c, d, e, a, K5, expand_store( 44 ), 3 ); - subRound( a, b, c, d, e, K5, expand_store( 45 ), 3 ); - subRound( e, a, b, c, d, K5, expand_store( 46 ), 3 ); - subRound( d, e, a, b, c, K5, expand_store( 47 ), 3 ); - subRound( c, d, e, a, b, K5, expand_store( 48 ), 3 ); - subRound( b, c, d, e, a, K5, expand_store( 49 ), 3 ); - subRound( a, b, c, d, e, K5, expand_store( 50 ), 3 ); - subRound( e, a, b, c, d, K5, expand_store( 51 ), 3 ); - subRound( d, e, a, b, c, K5, expand_store( 52 ), 3 ); - subRound( c, d, e, a, b, K5, expand_store( 53 ), 3 ); - subRound( b, c, d, e, a, K5, expand_store( 54 ), 3 ); - subRound( a, b, c, d, e, K5, expand_store( 55 ), 3 ); - subRound( e, a, b, c, d, K5, expand_store( 56 ), 3 ); - subRound( d, e, a, b, c, K5, expand_store( 57 ), 3 ); - subRound( c, d, e, a, b, K5, expand_store( 58 ), 3 ); - subRound( b, c, d, e, a, K5, expand_store( 59 ), 3 ); - - subRound( a, b, c, d, e, K10, expand_store( 60 ), 4 ); - subRound( e, a, b, c, d, K10, expand_store( 61 ), 4 ); - subRound( d, e, a, b, c, K10, expand_store( 62 ), 4 ); - subRound( c, d, e, a, b, K10, expand_store( 63 ), 4 ); - subRound( b, c, d, e, a, K10, expand_store( 64 ), 4 ); - subRound( a, b, c, d, e, K10, expand_store( 65 ), 4 ); - subRound( e, a, b, c, d, K10, expand_store( 66 ), 4 ); - subRound( d, e, a, b, c, K10, expand_store( 67 ), 4 ); - subRound( c, d, e, a, b, K10, expand_store( 68 ), 4 ); - subRound( b, c, d, e, a, K10, expand_store( 69 ), 4 ); - subRound( a, b, c, d, e, K10, expand_store( 70 ), 4 ); - subRound( e, a, b, c, d, K10, expand_store( 71 ), 4 ); - subRound( d, e, a, b, c, K10, expand_store( 72 ), 4 ); - subRound( c, d, e, a, b, K10, expand_store( 73 ), 4 ); - subRound( b, c, d, e, a, K10, expand_store( 74 ), 4 ); - subRound( a, b, c, d, e, K10, expand_store( 75 ), 4 ); - subRound( e, a, b, c, d, K10, expand_store( 76 ), 4 ); - subRound( d, e, a, b, c, K10, expand_nostore( 77 ), 4 ); - subRound( c, d, e, a, b, K10, expand_nostore( 78 ), 4 ); - subRound( b, c, d, e, a, K10, expand_nostore( 79 ), 4 ); - - hashdata[0] += a; - hashdata[1] += b; - hashdata[2] += c; - hashdata[3] += d; - hashdata[4] += e; -} - -#define BLOCKSIZE sizeof( data ) - -NIST_Hash::NIST_Hash( const char* pString, sal_uInt32 nLen ) -{ - hashdata[0] = 0x67452301; - hashdata[1] = 0xefcdab89; - hashdata[2] = 0x98badcfe; - hashdata[3] = 0x10325476; - hashdata[4] = 0xc3d2e1f0; - - sal_uInt32 nBytes = nLen; - - while( nLen >= sizeof( data ) ) - { - memcpy( data, pString, sizeof( data ) ); - pString += sizeof( data ); - nLen -= sizeof( data ); - transform(); - } - memcpy( data, pString, nLen ); - ((char*)data)[nLen++] = 0x80; - if( nLen > sizeof( data ) - 8 ) - { - memset( ((char*)data)+nLen, 0, sizeof( data ) - nLen ); - transform(); - memset( data, 0, sizeof( data ) - 8 ); - } - else - memset( ((char*)data)+nLen, 0, sizeof( data ) - 8 - nLen ); - data[14] = 0; - data[15] = nBytes << 3; - transform(); -} - -#ifdef TEST -#include <stdio.h> -int main( int argc, const char** argv ) -{ - const char* pHash = argc < 2 ? argv[0] : argv[1]; - - NIST_Hash aHash( pHash, strlen( pHash ) ); - sal_uInt32* pBits = aHash.getHash(); - - printf( "text : %s\n" - "bits : 0x%.8x 0x%.8x 0x%.8x 0x%.8x 0x%.8x\n", - pHash, - pBits[0], pBits[1], pBits[2],pBits[3],pBits[4] - ); - return 0; -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/uno2cpp.cxx b/bridges/source/cpp_uno/cc50_solaris_sparc/uno2cpp.cxx deleted file mode 100644 index 6fad40bfd33f..000000000000 --- a/bridges/source/cpp_uno/cc50_solaris_sparc/uno2cpp.cxx +++ /dev/null @@ -1,387 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <sal/alloca.h> - -#include <com/sun/star/uno/genfunc.hxx> -#include "com/sun/star/uno/RuntimeException.hpp" -#include <uno/data.h> - -#include "bridges/cpp_uno/shared/bridge.hxx" -#include "bridges/cpp_uno/shared/types.hxx" -#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx" -#include "bridges/cpp_uno/shared/vtables.hxx" - -#include "cc50_solaris_sparc.hxx" - -using namespace com::sun::star::uno; - -namespace -{ - -extern "C" void callVirtualMethod( - void * pAdjustedThisPtr, - sal_Int32 nVtableIndex, - void * pRegisterReturn, - typelib_TypeClass eReturnType, - sal_Int32 * pStackLongs, - sal_Int32 nStackLongs - ); - -//================================================================================================== -static void cpp_call( - bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, - bridges::cpp_uno::shared::VtableSlot aVtableSlot, - typelib_TypeDescriptionReference * pReturnTypeRef, - sal_Int32 nParams, typelib_MethodParameter * pParams, - void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc ) -{ - // pCppI is cc50_solaris_sparc this pointer - OSL_ENSURE( pThis, "### no interface given!" ); - - // max space for: [complex ret ptr], values|ptr ... - char * pCppStack = (char *)alloca( ((nParams+3) * sizeof(sal_Int64)) ); - char * pCppStackStart = pCppStack; - - // return - typelib_TypeDescription * pReturnTypeDescr = 0; - TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); - OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" ); - - void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion - - if (pReturnTypeDescr) - { - if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr )) - { - pCppReturn = pUnoReturn; // direct way for simple types - } - else - { - // complex return via ptr - pCppReturn = *(void **)pCppStack - = (bridges::cpp_uno::shared::relatesToInterfaceType( - pReturnTypeDescr ) - ? alloca( pReturnTypeDescr->nSize ) - : pUnoReturn); // direct way - pCppStack += sizeof(void *); - } - } - // push this - void * pAdjustedThisPtr = reinterpret_cast< void ** >(pThis->getCppI()) - + aVtableSlot.offset; - *(void**)pCppStack = pAdjustedThisPtr; - pCppStack += sizeof( void* ); - - // args - void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams ); - // indizes of values this have to be converted (interface conversion cpp<=>uno) - sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams); - // type descriptions for reconversions - typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams)); - - sal_Int32 nTempIndizes = 0; - - for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) - { - const typelib_MethodParameter & rParam = pParams[nPos]; - typelib_TypeDescription * pParamTypeDescr = 0; - TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); - - if (!rParam.bOut - && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) - { - pCppArgs[ nPos ] = CPPU_CURRENT_NAMESPACE::adjustPointer( - pCppStack, pParamTypeDescr ); - uno_copyAndConvertData( pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr, - pThis->getBridge()->getUno2Cpp() ); - - switch (pParamTypeDescr->eTypeClass) - { - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - case typelib_TypeClass_DOUBLE: - pCppStack += sizeof(sal_Int32); // extra long - } - // no longer needed - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - else // ptr to complex value | ref - { - if (! rParam.bIn) // is pure out - { - // cpp out is constructed mem, uno out is not! - uno_constructData( - *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ), - pParamTypeDescr ); - pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call - // will be released at reconversion - ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; - } - // is in/inout - else if (bridges::cpp_uno::shared::relatesToInterfaceType( - pParamTypeDescr )) - { - uno_copyAndConvertData( - *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ), - pUnoArgs[nPos], pParamTypeDescr, - pThis->getBridge()->getUno2Cpp() ); - - pTempIndizes[nTempIndizes] = nPos; // has to be reconverted - // will be released at reconversion - ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; - } - else // direct way - { - *(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos]; - // no longer needed - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - } - pCppStack += sizeof(sal_Int32); // standard parameter length - } - -// seems that EH registration for callVirtualMethod is not really -// necessary - -// static unsigned long* pFrameInfo = NULL; - -// if( ! pFrameInfo ) -// { -// pFrameInfo = new unsigned long[ 7 ]; -// pFrameInfo[ 0 ] = 0x40000000 | (((unsigned long)__Crun::ex_rethrow_q) >> 2); -// pFrameInfo[ 1 ] = 0x01000000; -// pFrameInfo[ 2 ] = (unsigned long)callVirtualMethodExceptionHandler; -// pFrameInfo[ 3 ] = 0; -// pFrameInfo[ 4 ] = (unsigned long)pFrameInfo - (unsigned long)callVirtualMethodExceptionHandler; -// pFrameInfo[ 5 ] = 0; -// pFrameInfo[ 6 ] = 0; -// _ex_register( pFrameInfo+2, 1 ); -// } - - try - { - int nStackLongs = (pCppStack - pCppStackStart)/sizeof(sal_Int32); - if( nStackLongs & 1 ) - // stack has to be 8 byte aligned - nStackLongs++; - - callVirtualMethod( - pAdjustedThisPtr, - aVtableSlot.index, - pCppReturn, - pReturnTypeDescr->eTypeClass, - (sal_Int32 *)pCppStackStart, - nStackLongs - ); - - // NO exception occurred... - *ppUnoExc = 0; - - // reconvert temporary params - for ( ; nTempIndizes--; ) - { - sal_Int32 nIndex = pTempIndizes[nTempIndizes]; - typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes]; - - if (pParams[nIndex].bIn) - { - if (pParams[nIndex].bOut) // inout - { - uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value - uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, - pThis->getBridge()->getCpp2Uno() ); - } - } - else // pure out - { - uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, - pThis->getBridge()->getCpp2Uno() ); - } - // destroy temp cpp param => cpp: every param was constructed - uno_destructData( - pCppArgs[nIndex], pParamTypeDescr, - reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - - TYPELIB_DANGER_RELEASE( pParamTypeDescr ); - } - // return value - if (pCppReturn && pUnoReturn != pCppReturn) - { - uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr, - pThis->getBridge()->getCpp2Uno() ); - uno_destructData( - pCppReturn, pReturnTypeDescr, - reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - } - } - catch( ... ) - { - void* pExc = __Crun::ex_get(); - const char* pName = __Cimpl::ex_name(); - - // get exception - CPPU_CURRENT_NAMESPACE::cc50_solaris_sparc_fillUnoException( - pExc, pName, *ppUnoExc, pThis->getBridge()->getCpp2Uno()); - - // temporary params - for ( ; nTempIndizes--; ) - { - sal_Int32 nIndex = pTempIndizes[nTempIndizes]; - // destroy temp cpp param => cpp: every param was constructed - uno_destructData( - pCppArgs[nIndex], - ppTempParamTypeDescr[nTempIndizes], - reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] ); - } - // return type - if (pReturnTypeDescr) - TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); - } -} - -} - -namespace bridges { namespace cpp_uno { namespace shared { - -void unoInterfaceProxyDispatch( - uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr, - void * pReturn, void * pArgs[], uno_Any ** ppException ) -{ - // is my surrogate - bridges::cpp_uno::shared::UnoInterfaceProxy * pThis - = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI); - typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr; - - switch (pMemberDescr->eTypeClass) - { - case typelib_TypeClass_INTERFACE_ATTRIBUTE: - { - VtableSlot aVtableSlot( - getVtableSlot( - reinterpret_cast< - typelib_InterfaceAttributeTypeDescription const * >( - pMemberDescr))); - if (pReturn) - { - // dependent dispatch - cpp_call( - pThis, aVtableSlot, - ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef, - 0, 0, // no params - pReturn, pArgs, ppException ); - } - else - { - // is SET - typelib_MethodParameter aParam; - aParam.pTypeRef = - ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef; - aParam.bIn = sal_True; - aParam.bOut = sal_False; - - typelib_TypeDescriptionReference * pReturnTypeRef = 0; - OUString aVoidName( "void" ); - typelib_typedescriptionreference_new( - &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData ); - - // dependent dispatch - aVtableSlot.index += 1; // get, then set method - cpp_call( - pThis, aVtableSlot, - pReturnTypeRef, - 1, &aParam, - pReturn, pArgs, ppException ); - - typelib_typedescriptionreference_release( pReturnTypeRef ); - } - - break; - } - case typelib_TypeClass_INTERFACE_METHOD: - { - VtableSlot aVtableSlot( - getVtableSlot( - reinterpret_cast< - typelib_InterfaceMethodTypeDescription const * >( - pMemberDescr))); - switch (aVtableSlot.index) - { - // standard calls - case 1: // acquire uno interface - (*pUnoI->acquire)( pUnoI ); - *ppException = 0; - break; - case 2: // release uno interface - (*pUnoI->release)( pUnoI ); - *ppException = 0; - break; - case 0: // queryInterface() opt - { - typelib_TypeDescription * pTD = 0; - TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() ); - if (pTD) - { - uno_Interface * pInterface = 0; - (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)( - pThis->pBridge->getUnoEnv(), - (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD ); - - if (pInterface) - { - ::uno_any_construct( - reinterpret_cast< uno_Any * >( pReturn ), - &pInterface, pTD, 0 ); - (*pInterface->release)( pInterface ); - TYPELIB_DANGER_RELEASE( pTD ); - *ppException = 0; - break; - } - TYPELIB_DANGER_RELEASE( pTD ); - } - } // else perform queryInterface() - default: - // dependent dispatch - cpp_call( - pThis, aVtableSlot, - ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef, - ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams, - ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams, - pReturn, pArgs, ppException ); - } - break; - } - default: - { - ::com::sun::star::uno::RuntimeException aExc( - "illegal member type description!", - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() ); - - Type const & rExcType = ::getCppuType( &aExc ); - // binary identical null reference - ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 ); - } - } -} - -} } } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.hxx deleted file mode 100644 index b233fa02f357..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.hxx +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_CALLVIRTUALMETHOD_Hx -#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_CALLVIRTUALMETHOD_Hx - -#include "sal/config.h" - -extern "C" void callVirtualMethod( - unsigned long function, long * stack, sal_Int32 excess); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.s b/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.s deleted file mode 100644 index 26e4ed5ef3d4..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.s +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -.global callVirtualMethod -.align 8 -callVirtualMethod: - ! %o0: unsigned long function - ! %o1: unsigned long * stack - ! %o2: sal_Int32 excess - add %o2, 176, %o3 - neg %o3 - save %sp, %o3, %sp - ldx [%i1 + 0 * 8], %o0 - ldx [%i1 + 1 * 8], %o1 - ldx [%i1 + 2 * 8], %o2 - ldx [%i1 + 3 * 8], %o3 - tst %i2 - bz,pt %xcc, 1f - ldx [%i1 + 4 * 8], %o4 - add %i1, 6 * 8, %l0 - add %sp, 2047 + 176, %l1 -0: deccc 8, %i2 - ldx [%l0 + %i2], %l2 - bnz,pt %xcc, 0b - stx %l2, [%l1 + %i2] -1: call %i0 - ldx [%i1 + 5 * 8], %o5 - stx %o0, [%i1 + 0 * 8] - stx %o1, [%i1 + 1 * 8] - stx %o2, [%i1 + 2 * 8] - stx %o3, [%i1 + 3 * 8] - ret - restore -.size callVirtualMethod, . - callVirtualMethod -.type callVirtualMethod, #function diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/cpp2uno.cxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/cpp2uno.cxx deleted file mode 100644 index 7f9323f865ca..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/cpp2uno.cxx +++ /dev/null @@ -1,602 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "sal/config.h" - -#include <cstddef> -#include <cstdlib> -#include <cstring> - -#include "bridges/cpp_uno/shared/bridge.hxx" -#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx" -#include "bridges/cpp_uno/shared/types.hxx" -#include "bridges/cpp_uno/shared/vtablefactory.hxx" -#include "com/sun/star/uno/genfunc.hxx" -#include "osl/diagnose.h" -#include "sal/alloca.h" -#include "sal/types.h" -#include "typelib/typeclass.h" -#include "typelib/typedescription.h" -#include "typelib/typedescription.hxx" -#include "uno/any2.h" -#include "uno/data.h" - -#include "exceptions.hxx" -#include "flushcode.hxx" -#include "fp.hxx" -#include "isdirectreturntype.hxx" -#include "vtableslotcall.hxx" - -namespace { - -void loadFpRegsFromStruct(typelib_TypeDescription * type, void * data) { - for (typelib_CompoundTypeDescription * t = - reinterpret_cast< typelib_CompoundTypeDescription * >(type); - t != NULL; t = t->pBaseTypeDescription) - { - for (sal_Int32 i = 0; i < t->nMembers; ++i) { - switch (t->ppTypeRefs[i]->eTypeClass) { - case typelib_TypeClass_FLOAT: - switch (t->pMemberOffsets[i]) { - case 0: - fp_loadf0(reinterpret_cast< float * >(data)); - break; - case 4: - fp_loadf1(reinterpret_cast< float * >(data) + 1); - break; - case 8: - fp_loadf2(reinterpret_cast< float * >(data) + 2); - break; - case 12: - fp_loadf3(reinterpret_cast< float * >(data) + 3); - break; - case 16: - fp_loadf4(reinterpret_cast< float * >(data) + 4); - break; - case 20: - fp_loadf5(reinterpret_cast< float * >(data) + 5); - break; - case 24: - fp_loadf6(reinterpret_cast< float * >(data) + 6); - break; - case 28: - fp_loadf7(reinterpret_cast< float * >(data) + 7); - break; - default: - OSL_ASSERT(false); - break; - } - break; - case typelib_TypeClass_DOUBLE: - switch (t->pMemberOffsets[i]) { - case 0: - fp_loadd0(reinterpret_cast< double * >(data)); - break; - case 8: - fp_loadd2(reinterpret_cast< double * >(data) + 1); - break; - case 16: - fp_loadd4(reinterpret_cast< double * >(data) + 2); - break; - case 24: - fp_loadd6(reinterpret_cast< double * >(data) + 3); - break; - default: - OSL_ASSERT(false); - break; - } - break; - case typelib_TypeClass_STRUCT: - { - typelib_TypeDescription * td = NULL; - TYPELIB_DANGER_GET(&td, t->ppTypeRefs[i]); - loadFpRegsFromStruct(td, data); - TYPELIB_DANGER_RELEASE(td); - break; - } - } - } - } -} - -void call( - bridges::cpp_uno::shared::CppInterfaceProxy * proxy, - css::uno::TypeDescription const & description, - bool directReturn, typelib_TypeDescriptionReference * returnType, - sal_Int32 count, typelib_MethodParameter * parameters, - unsigned long * callStack) -{ - typelib_TypeDescription * rtd = NULL; - if (returnType != NULL) { - TYPELIB_DANGER_GET(&rtd, returnType); - } - bool retconv = - rtd != NULL && bridges::cpp_uno::shared::relatesToInterfaceType(rtd); - OSL_ASSERT(!(directReturn && retconv)); - void * retin; - void * retout; - char retbuf[32]; - if (directReturn) { - retin = returnType == NULL ? NULL : retbuf; - } else { - retout = reinterpret_cast< void * >(callStack[0]); - retin = retconv ? alloca(rtd->nSize) : retout; - } - void ** args = static_cast< void ** >(alloca(count * sizeof (void *))); - void ** cppArgs = static_cast< void ** >(alloca(count * sizeof (void *))); - typelib_TypeDescription ** argtds = - static_cast< typelib_TypeDescription ** >( - alloca(count * sizeof (typelib_TypeDescription *))); - union fp { float f; double d; }; - fp copies[15]; - sal_Int32 stackPos = directReturn ? 1 : 2; // skip return ptr and this ptr - for (sal_Int32 i = 0; i < count; ++i) { - typelib_TypeDescription * ptd = NULL; - TYPELIB_DANGER_GET(&ptd, parameters[i].pTypeRef); - if (!parameters[i].bOut && bridges::cpp_uno::shared::isSimpleType(ptd)) - { - switch (ptd->eTypeClass) { - case typelib_TypeClass_FLOAT: - if (stackPos <= 15) { - switch (stackPos) { - case 1: - fp_storef3(&copies[0].f); - break; - case 2: - fp_storef5(&copies[1].f); - break; - case 3: - fp_storef7(&copies[2].f); - break; - case 4: - fp_storef9(&copies[3].f); - break; - case 5: - fp_storef11(&copies[4].f); - break; - case 6: - fp_storef13(&copies[5].f); - break; - case 7: - fp_storef15(&copies[6].f); - break; - case 8: - fp_storef17(&copies[7].f); - break; - case 9: - fp_storef19(&copies[8].f); - break; - case 10: - fp_storef21(&copies[9].f); - break; - case 11: - fp_storef23(&copies[10].f); - break; - case 12: - fp_storef25(&copies[11].f); - break; - case 13: - fp_storef27(&copies[12].f); - break; - case 14: - fp_storef29(&copies[13].f); - break; - case 15: - fp_storef31(&copies[14].f); - break; - default: - OSL_ASSERT(false); - break; - } - args[i] = &copies[stackPos - 1].f; - } else { - args[i] = reinterpret_cast< char * >(callStack + stackPos) + - (sizeof (unsigned long) - sizeof (float)); - } - break; - case typelib_TypeClass_DOUBLE: - if (stackPos <= 15) { - switch (stackPos) { - case 1: - fp_stored2(&copies[0].d); - break; - case 2: - fp_stored4(&copies[1].d); - break; - case 3: - fp_stored6(&copies[2].d); - break; - case 4: - fp_stored8(&copies[3].d); - break; - case 5: - fp_stored10(&copies[4].d); - break; - case 6: - fp_stored12(&copies[5].d); - break; - case 7: - fp_stored14(&copies[6].d); - break; - case 8: - fp_stored16(&copies[7].d); - break; - case 9: - fp_stored18(&copies[8].d); - break; - case 10: - fp_stored20(&copies[9].d); - break; - case 11: - fp_stored22(&copies[10].d); - break; - case 12: - fp_stored24(&copies[11].d); - break; - case 13: - fp_stored26(&copies[12].d); - break; - case 14: - fp_stored28(&copies[13].d); - break; - case 15: - fp_stored30(&copies[14].d); - break; - default: - OSL_ASSERT(false); - break; - } - args[i] = &copies[stackPos - 1].d; - } else { - args[i] = reinterpret_cast< char * >(callStack + stackPos) + - (sizeof (unsigned long) - sizeof (double)); - } - break; - default: - OSL_ASSERT(ptd->nSize <= 8); - args[i] = reinterpret_cast< char * >(callStack + stackPos) + - (sizeof (unsigned long) - ptd->nSize); - break; - } - argtds[i] = NULL; - TYPELIB_DANGER_RELEASE(ptd); - } else { - cppArgs[i] = reinterpret_cast< void * >(callStack[stackPos]); - if (!parameters[i].bIn) { - args[i] = alloca(ptd->nSize); - argtds[i] = ptd; - } else if (bridges::cpp_uno::shared::relatesToInterfaceType(ptd)) { - args[i] = alloca(ptd->nSize); - uno_copyAndConvertData( - args[i], reinterpret_cast< void * >(callStack[stackPos]), - ptd, proxy->getBridge()->getCpp2Uno()); - argtds[i] = ptd; - } else { - args[i] = reinterpret_cast< void * >(callStack[stackPos]); - argtds[i] = NULL; - TYPELIB_DANGER_RELEASE(ptd); - } - } - ++stackPos; - } - uno_Any exc; - uno_Any * pexc = &exc; - proxy->getUnoI()->pDispatcher( - proxy->getUnoI(), description.get(), retin, args, &pexc); - if (pexc != NULL) { - for (sal_Int32 i = 0; i < count; ++i) { - if (argtds[i] != NULL) { - if (parameters[i].bIn) { - uno_destructData(args[i], argtds[i], NULL); - } - TYPELIB_DANGER_RELEASE(argtds[i]); - } - } - if (rtd != NULL) { - TYPELIB_DANGER_RELEASE(rtd); - } - bridges::cpp_uno::cc5_solaris_sparc64::raiseException( - &exc, proxy->getBridge()->getUno2Cpp()); - std::abort(); // just in case - } - for (sal_Int32 i = 0; i < count; ++i) { - if (argtds[i] != NULL) { - if (parameters[i].bOut) { - uno_destructData( - cppArgs[i], argtds[i], - reinterpret_cast< uno_ReleaseFunc >(css::uno::cpp_release)); - uno_copyAndConvertData( - cppArgs[i], args[i], argtds[i], - proxy->getBridge()->getUno2Cpp()); - } - uno_destructData(args[i], argtds[i], NULL); - TYPELIB_DANGER_RELEASE(argtds[i]); - } - } - if (directReturn) { - if (rtd != NULL) { - switch (rtd->eTypeClass) { - case typelib_TypeClass_VOID: - break; - case typelib_TypeClass_BOOLEAN: - callStack[0] = *reinterpret_cast< sal_Bool * >(retbuf); - break; - case typelib_TypeClass_BYTE: - callStack[0] = *reinterpret_cast< sal_Int8 * >(retbuf); - break; - case typelib_TypeClass_SHORT: - callStack[0] = *reinterpret_cast< sal_Int16 * >(retbuf); - break; - case typelib_TypeClass_UNSIGNED_SHORT: - callStack[0] = *reinterpret_cast< sal_uInt16 * >(retbuf); - break; - case typelib_TypeClass_LONG: - case typelib_TypeClass_ENUM: - callStack[0] = *reinterpret_cast< sal_Int32 * >(retbuf); - break; - case typelib_TypeClass_UNSIGNED_LONG: - callStack[0] = *reinterpret_cast< sal_uInt32 * >(retbuf); - break; - case typelib_TypeClass_HYPER: - callStack[0] = *reinterpret_cast< sal_Int64 * >(retbuf); - break; - case typelib_TypeClass_UNSIGNED_HYPER: - callStack[0] = *reinterpret_cast< sal_uInt64 * >(retbuf); - break; - case typelib_TypeClass_FLOAT: - fp_loadf0(reinterpret_cast< float * >(retbuf)); - break; - case typelib_TypeClass_DOUBLE: - fp_loadd0(reinterpret_cast< double * >(retbuf)); - break; - case typelib_TypeClass_CHAR: - callStack[0] = *reinterpret_cast< sal_Unicode * >(retbuf); - break; - case typelib_TypeClass_STRING: - case typelib_TypeClass_TYPE: - case typelib_TypeClass_SEQUENCE: - case typelib_TypeClass_INTERFACE: - callStack[0] = reinterpret_cast< unsigned long >( - *reinterpret_cast< void ** >(retbuf)); - break; - case typelib_TypeClass_STRUCT: - loadFpRegsFromStruct(rtd, retbuf); - // fall through - case typelib_TypeClass_ANY: - std::memcpy(callStack, retbuf, rtd->nSize); - break; - default: - OSL_ASSERT(false); - break; - } - } - } else if (retconv) { - uno_copyAndConvertData( - retout, retin, rtd, proxy->getBridge()->getUno2Cpp()); - uno_destructData(retin, rtd, NULL); - } - if (rtd != NULL) { - TYPELIB_DANGER_RELEASE(rtd); - } -} - -extern "C" void vtableCall( - sal_Int32 functionIndex, sal_Int32 vtableOffset, unsigned long * callStack) -{ - bool direct = static_cast< sal_uInt32 >((functionIndex) & 0x80000000) == 0; - functionIndex = static_cast< sal_uInt32 >(functionIndex) & 0x7FFFFFFF; - bridges::cpp_uno::shared::CppInterfaceProxy * proxy - = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy( - reinterpret_cast< char * >(callStack[direct ? 0 : 1]) - - vtableOffset); - typelib_InterfaceTypeDescription * type = proxy->getTypeDescr(); - OSL_ASSERT(functionIndex < type->nMapFunctionIndexToMemberIndex); - sal_Int32 pos = type->pMapFunctionIndexToMemberIndex[functionIndex]; - css::uno::TypeDescription desc(type->ppAllMembers[pos]); - switch (desc.get()->eTypeClass) { - case typelib_TypeClass_INTERFACE_ATTRIBUTE: - if (type->pMapMemberIndexToFunctionIndex[pos] == functionIndex) { - // Getter: - call( - proxy, desc, direct, - reinterpret_cast< typelib_InterfaceAttributeTypeDescription * >( - desc.get())->pAttributeTypeRef, - 0, NULL, callStack); - } else { - // Setter: - typelib_MethodParameter param = { - NULL, - reinterpret_cast< typelib_InterfaceAttributeTypeDescription * >( - desc.get())->pAttributeTypeRef, - true, false }; - call(proxy, desc, true, NULL, 1, ¶m, callStack); - } - break; - case typelib_TypeClass_INTERFACE_METHOD: - switch (functionIndex) { - case 1: - proxy->acquireProxy(); - break; - case 2: - proxy->releaseProxy(); - break; - case 0: - { - typelib_TypeDescription * td = NULL; - TYPELIB_DANGER_GET( - &td, - reinterpret_cast< css::uno::Type * >( - callStack[2])->getTypeLibType()); - if (td != NULL) { - css::uno::XInterface * ifc = NULL; - proxy->getBridge()->getCppEnv()->getRegisteredInterface( - proxy->getBridge()->getCppEnv(), - reinterpret_cast< void ** >(&ifc), - proxy->getOid().pData, - reinterpret_cast< typelib_InterfaceTypeDescription * >( - td)); - if (ifc != NULL) { - uno_any_construct( - reinterpret_cast< uno_Any * >(callStack[0]), &ifc, - td, - reinterpret_cast< uno_AcquireFunc >( - css::uno::cpp_acquire)); - ifc->release(); - TYPELIB_DANGER_RELEASE(td); - break; - } - TYPELIB_DANGER_RELEASE(td); - } - } // fall through - default: - call( - proxy, desc, direct, - reinterpret_cast< typelib_InterfaceMethodTypeDescription * >( - desc.get())->pReturnTypeRef, - reinterpret_cast< typelib_InterfaceMethodTypeDescription * >( - desc.get())->nParams, - reinterpret_cast< typelib_InterfaceMethodTypeDescription * >( - desc.get())->pParams, - callStack); - } - break; - default: - OSL_ASSERT(false); - break; - } -} - -int const codeSnippetSize = 10 * 4; - -unsigned char * generateCodeSnippet( - unsigned char * code, sal_Int32 functionIndex, sal_Int32 vtableOffset, - bool directReturn) -{ - sal_uInt32 index = functionIndex; - if (!directReturn) { - index |= 0x80000000; - } - unsigned int * p = reinterpret_cast< unsigned int * >(code); - OSL_ASSERT(sizeof (unsigned int) == 4); - // 0*4: save %sp, -176, %sp ! minimal stack frame: - *p++ = 0x9DE3BF50; - // 1*4: rd %pc, %l0: - *p++ = 0xA1414000; - // 2*4: ldx %l0, (8-1)*4, %l0: - *p++ = 0xE05C201C; - // 3*4: sethi %hi(index), %o0: - *p++ = 0x11000000 | (index >> 10); - // 4*4: or %o0, %lo(index), %o0: - *p++ = 0x90122000 | (index & 0x3FF); - // 5*4: sethi %hi(vtableOffset), %o1: - *p++ = 0x13000000 | (vtableOffset >> 10); - // 6*4: jmpl %l0, %g0, %g0: - *p++ = 0x81C40000; - // 7*4: or %o1, %lo(vtableOffset), %o1: - *p++ = 0x92126000 | (vtableOffset & 0x3FF); - // 8*4: .xword privateSnippetExecutor: - *reinterpret_cast< unsigned long * >(p) = - reinterpret_cast< unsigned long >(vtableSlotCall); - return code + codeSnippetSize; -} - -} - -struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; }; - -bridges::cpp_uno::shared::VtableFactory::Slot * -bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block) { - return static_cast< Slot * >(block) + 1; -} - -sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize( - sal_Int32 slotCount) -{ - return (slotCount + 3) * sizeof (Slot) + slotCount * codeSnippetSize; -} - -bridges::cpp_uno::shared::VtableFactory::Slot * -bridges::cpp_uno::shared::VtableFactory::initializeBlock( - void * block, sal_Int32 slotCount) -{ - Slot * slots = mapBlockToVtable(block) + 2; - slots[-3].fn = NULL; // RTTI - slots[-2].fn = NULL; // null - slots[-1].fn = NULL; // destructor - return slots + slotCount; -} - -unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( - Slot ** slots, unsigned char * code, - typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset, - sal_Int32 functionCount, sal_Int32 vtableOffset) -{ - (*slots) -= functionCount; - Slot * s = *slots; - for (sal_Int32 i = 0; i < type->nMembers; ++i) { - typelib_TypeDescription * member = 0; - TYPELIB_DANGER_GET(&member, type->ppMembers[i]); - OSL_ASSERT(member != 0); - switch (member->eTypeClass) { - case typelib_TypeClass_INTERFACE_ATTRIBUTE: - // Getter: - (s++)->fn = code; - code = generateCodeSnippet( - code, functionOffset++, vtableOffset, - bridges::cpp_uno::cc5_solaris_sparc64::isDirectReturnType( - reinterpret_cast< - typelib_InterfaceAttributeTypeDescription * >( - member)->pAttributeTypeRef)); - // Setter: - if (!reinterpret_cast< - typelib_InterfaceAttributeTypeDescription * >( - member)->bReadOnly) - { - (s++)->fn = code; - code = generateCodeSnippet( - code, functionOffset++, vtableOffset, true); - } - break; - - case typelib_TypeClass_INTERFACE_METHOD: - (s++)->fn = code; - code = generateCodeSnippet( - code, functionOffset++, vtableOffset, - bridges::cpp_uno::cc5_solaris_sparc64::isDirectReturnType( - reinterpret_cast< - typelib_InterfaceMethodTypeDescription * >( - member)->pReturnTypeRef)); - break; - - default: - OSL_ASSERT(false); - break; - } - TYPELIB_DANGER_RELEASE(member); - } - return code; -} - -void bridges::cpp_uno::shared::VtableFactory::flushCode( - unsigned char const * begin, unsigned char const * end) -{ - bridges::cpp_uno::cc5_solaris_sparc64::flushCode(begin, end); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.cxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.cxx deleted file mode 100644 index f8bfc926488f..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.cxx +++ /dev/null @@ -1,448 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "sal/config.h" - -#include <cstddef> -#include <cstring> -#include <map> -#include <utility> -#include <vector> - -#include "bridges/cpp_uno/shared/arraypointer.hxx" -#include "com/sun/star/uno/Reference.hxx" -#include "com/sun/star/uno/RuntimeException.hpp" -#include "com/sun/star/uno/XInterface.hpp" -#include "com/sun/star/uno/genfunc.hxx" -#include "osl/diagnose.h" -#include "osl/mutex.hxx" -#include "rtl/strbuf.hxx" -#include "rtl/string.hxx" -#include "rtl/textenc.h" -#include "rtl/ustring.h" -#include "rtl/ustring.hxx" -#include "sal/types.h" -#include "typelib/typeclass.h" -#include "typelib/typedescription.h" -#include "uno/any2.h" -#include "uno/data.h" -#include "uno/mapping.h" - -#include "exceptions.hxx" -#include "flushcode.hxx" - -namespace { - -typedef void (* Function)(void *); - -Function toFunction(void * pointer) { -#pragma disable_warn - return reinterpret_cast< Function >(pointer); -#pragma enable_warn -} - -bool toUnoName(char const * rttiName, OUString * unoName) { - rtl::OStringBuffer buf; - for (;;) { - char const * p = std::strchr(rttiName, ':'); - if (p == NULL) { - buf.append(rttiName); - break; - } - if (p - rttiName > SAL_MAX_INT32) { - return false; - } - buf.append(rttiName, sal::static_int_cast< sal_Int32 >(p - rttiName)); - buf.append("."); - while (*p == ':') { - ++p; - } - rttiName = p; - } - *unoName = rtl::OStringToOUString( - buf.makeStringAndClear(), RTL_TEXTENCODING_UTF8); - //TODO: check conversion failure - return true; -} - -class NistHash { -public: - NistHash(rtl::OString const & text); - - sal_uInt32 hashdata[5]; - -private: - static sal_uInt32 f1(sal_uInt32 x, sal_uInt32 y, sal_uInt32 z) - { return z ^ (x & (y ^ z)); } - - static sal_uInt32 f2(sal_uInt32 x, sal_uInt32 y, sal_uInt32 z) - { return x ^ y ^ z; } - - static sal_uInt32 f3(sal_uInt32 x, sal_uInt32 y, sal_uInt32 z) - { return (x & y) + (z & (x ^ y)); } - - static sal_uInt32 rotl(sal_uInt32 value, sal_uInt32 bits) - { return (value << bits) | (value >> (32 - bits)); } - - sal_uInt32 expand_nostore(sal_uInt32 index) { - return data[index & 15] ^ data[(index - 14) & 15] ^ - data[(index - 8) & 15] ^ data[(index - 3) & 15]; - } - - sal_uInt32 expand_store(sal_uInt32 index) { - return data[index & 15] ^= data[(index - 14) & 15] ^ - data[(index - 8) & 15] ^ data[(index - 3) & 15]; - } - - void subRound( - sal_uInt32 a, sal_uInt32 & b, sal_uInt32 c, sal_uInt32 d, - sal_uInt32 & e, sal_uInt32 constant, sal_uInt32 datum, - sal_uInt32 function) - { - e += rotl(a, 5); - switch (function) { - case 1: - e += f1(b, c, d); - break; - case 2: - case 4: - e += f2(b, c, d); - break; - case 3: - e += f3(b, c, d); - break; - } - e += constant + datum; - b = rotl(b, 30); - } - - void transform(); - - sal_uInt32 data[16]; -}; - -NistHash::NistHash(rtl::OString const & text) { - hashdata[0] = 0x67452301; - hashdata[1] = 0xefcdab89; - hashdata[2] = 0x98badcfe; - hashdata[3] = 0x10325476; - hashdata[4] = 0xc3d2e1f0; - char const * p = text.getStr(); - sal_Int32 n = text.getLength(); - while (n >= sizeof data) { - std::memcpy(data, p, sizeof data); - p += sizeof data; - n -= sizeof data; - transform(); - } - std::memcpy(data, p, n); - reinterpret_cast< unsigned char *>(data)[n++] = 0x80; - if (n > sizeof data - 8) { - std::memset(reinterpret_cast< char * >(data) + n, 0, sizeof data - n); - transform(); - std::memset(data, 0, sizeof data - 8); - } else { - std::memset( - reinterpret_cast< char * >(data) + n, 0, sizeof data - 8 - n); - } - data[14] = 0; - data[15] = text.getLength() << 3; - transform(); -} - -void NistHash::transform() { - sal_uInt32 const K2 = 0x5A827999; - sal_uInt32 const K3 = 0x6ED9EBA1; - sal_uInt32 const K5 = 0x8F1BBCDC; - sal_uInt32 const K10 = 0xCA62C1D6; - sal_uInt32 a = hashdata[0]; - sal_uInt32 b = hashdata[1]; - sal_uInt32 c = hashdata[2]; - sal_uInt32 d = hashdata[3]; - sal_uInt32 e = hashdata[4]; - subRound(a, b, c, d, e, K2, data[ 0], 1); - subRound(e, a, b, c, d, K2, data[ 1], 1); - subRound(d, e, a, b, c, K2, data[ 2], 1); - subRound(c, d, e, a, b, K2, data[ 3], 1); - subRound(b, c, d, e, a, K2, data[ 4], 1); - subRound(a, b, c, d, e, K2, data[ 5], 1); - subRound(e, a, b, c, d, K2, data[ 6], 1); - subRound(d, e, a, b, c, K2, data[ 7], 1); - subRound(c, d, e, a, b, K2, data[ 8], 1); - subRound(b, c, d, e, a, K2, data[ 9], 1); - subRound(a, b, c, d, e, K2, data[10], 1); - subRound(e, a, b, c, d, K2, data[11], 1); - subRound(d, e, a, b, c, K2, data[12], 1); - subRound(c, d, e, a, b, K2, data[13], 1); - subRound(b, c, d, e, a, K2, data[14], 1); - subRound(a, b, c, d, e, K2, data[15], 1); - subRound(e, a, b, c, d, K2, expand_store(16), 1); - subRound(d, e, a, b, c, K2, expand_store(17), 1); - subRound(c, d, e, a, b, K2, expand_store(18), 1); - subRound(b, c, d, e, a, K2, expand_store(19), 1); - subRound(a, b, c, d, e, K3, expand_store(20), 2); - subRound(e, a, b, c, d, K3, expand_store(21), 2); - subRound(d, e, a, b, c, K3, expand_store(22), 2); - subRound(c, d, e, a, b, K3, expand_store(23), 2); - subRound(b, c, d, e, a, K3, expand_store(24), 2); - subRound(a, b, c, d, e, K3, expand_store(25), 2); - subRound(e, a, b, c, d, K3, expand_store(26), 2); - subRound(d, e, a, b, c, K3, expand_store(27), 2); - subRound(c, d, e, a, b, K3, expand_store(28), 2); - subRound(b, c, d, e, a, K3, expand_store(29), 2); - subRound(a, b, c, d, e, K3, expand_store(30), 2); - subRound(e, a, b, c, d, K3, expand_store(31), 2); - subRound(d, e, a, b, c, K3, expand_store(32), 2); - subRound(c, d, e, a, b, K3, expand_store(33), 2); - subRound(b, c, d, e, a, K3, expand_store(34), 2); - subRound(a, b, c, d, e, K3, expand_store(35), 2); - subRound(e, a, b, c, d, K3, expand_store(36), 2); - subRound(d, e, a, b, c, K3, expand_store(37), 2); - subRound(c, d, e, a, b, K3, expand_store(38), 2); - subRound(b, c, d, e, a, K3, expand_store(39), 2); - subRound(a, b, c, d, e, K5, expand_store(40), 3); - subRound(e, a, b, c, d, K5, expand_store(41), 3); - subRound(d, e, a, b, c, K5, expand_store(42), 3); - subRound(c, d, e, a, b, K5, expand_store(43), 3); - subRound(b, c, d, e, a, K5, expand_store(44), 3); - subRound(a, b, c, d, e, K5, expand_store(45), 3); - subRound(e, a, b, c, d, K5, expand_store(46), 3); - subRound(d, e, a, b, c, K5, expand_store(47), 3); - subRound(c, d, e, a, b, K5, expand_store(48), 3); - subRound(b, c, d, e, a, K5, expand_store(49), 3); - subRound(a, b, c, d, e, K5, expand_store(50), 3); - subRound(e, a, b, c, d, K5, expand_store(51), 3); - subRound(d, e, a, b, c, K5, expand_store(52), 3); - subRound(c, d, e, a, b, K5, expand_store(53), 3); - subRound(b, c, d, e, a, K5, expand_store(54), 3); - subRound(a, b, c, d, e, K5, expand_store(55), 3); - subRound(e, a, b, c, d, K5, expand_store(56), 3); - subRound(d, e, a, b, c, K5, expand_store(57), 3); - subRound(c, d, e, a, b, K5, expand_store(58), 3); - subRound(b, c, d, e, a, K5, expand_store(59), 3); - subRound(a, b, c, d, e, K10, expand_store(60), 4); - subRound(e, a, b, c, d, K10, expand_store(61), 4); - subRound(d, e, a, b, c, K10, expand_store(62), 4); - subRound(c, d, e, a, b, K10, expand_store(63), 4); - subRound(b, c, d, e, a, K10, expand_store(64), 4); - subRound(a, b, c, d, e, K10, expand_store(65), 4); - subRound(e, a, b, c, d, K10, expand_store(66), 4); - subRound(d, e, a, b, c, K10, expand_store(67), 4); - subRound(c, d, e, a, b, K10, expand_store(68), 4); - subRound(b, c, d, e, a, K10, expand_store(69), 4); - subRound(a, b, c, d, e, K10, expand_store(70), 4); - subRound(e, a, b, c, d, K10, expand_store(71), 4); - subRound(d, e, a, b, c, K10, expand_store(72), 4); - subRound(c, d, e, a, b, K10, expand_store(73), 4); - subRound(b, c, d, e, a, K10, expand_store(74), 4); - subRound(a, b, c, d, e, K10, expand_store(75), 4); - subRound(e, a, b, c, d, K10, expand_store(76), 4); - subRound(d, e, a, b, c, K10, expand_nostore(77), 4); - subRound(c, d, e, a, b, K10, expand_nostore(78), 4); - subRound(b, c, d, e, a, K10, expand_nostore(79), 4); - hashdata[0] += a; - hashdata[1] += b; - hashdata[2] += c; - hashdata[3] += d; - hashdata[4] += e; -} - -class RttiMap { -public: - static __Crun::static_type_info const * get( - typelib_CompoundTypeDescription const * type); - -private: - RttiMap(); // not defined - RttiMap(RttiMap &); // not defined - ~RttiMap(); // not defined - void operator =(RttiMap &); // not defined - - struct Data { - __Crun::static_type_info * info; - rtl::OString cppName; - std::vector< __Crun::class_base_descr > bases; - }; - typedef std::map< OUString, Data > Map; - - static void toCppNames( - OUString const & unoName, OString * cppName, - OString * rttiName); - - static Data const & get_(typelib_CompoundTypeDescription const * type); - - static osl::Mutex m_mutex; - static Map * m_map; -}; - -osl::Mutex RttiMap::m_mutex; -RttiMap::Map * RttiMap::m_map; - -__Crun::static_type_info const * RttiMap::get( - typelib_CompoundTypeDescription const * type) -{ - osl::MutexGuard g(m_mutex); - if (m_map == NULL) { - m_map = new Map; // leaked - } - return get_(type).info; -} - -void RttiMap::toCppNames( - OUString const & unoName, OString * cppName, - OString * rttiName) -{ - OSL_ASSERT(cppName != NULL && rttiName != NULL); - rtl::OStringBuffer bc; - rtl::OStringBuffer br; - br.append("__1n"); - for (sal_Int32 i = 0; i != -1;) { - OUString tok(unoName.getToken(0, '.', i)); - bc.append(OUStringToOString(tok, RTL_TEXTENCODING_UTF8)); - // conversion should never fail, as tok should be well-formed ASCII - if (i != -1) { - bc.append("::"); - } - sal_Int32 len = tok.getLength(); - sal_Int32 pos = br.getLength(); - for (sal_Int32 n = len / 26; n > 0; n /= 26) { - br.insert(pos, static_cast< char >('a' + (n % 26))); - } - br.append(static_cast< char >('A' + (len % 26))); - for (sal_Int32 j = 0; j < len; ++j) { - sal_Unicode c = tok[j]; - OSL_ASSERT( - c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || - c >= 'a' && c <= 'z'); - if (c == 'Q') { - br.append("QdD"); - } else { - br.append(static_cast< char >(c)); - } - } - } - br.append('_'); - *cppName = bc.makeStringAndClear(); - *rttiName = br.makeStringAndClear(); -} - -RttiMap::Data const & RttiMap::get_( - typelib_CompoundTypeDescription const * type) -{ - OUString name(type->aBase.pTypeName); - Map::iterator it(m_map->find(name)); - if (it == m_map->end()) { - it = m_map->insert(std::make_pair(name, Data())).first; - Data & data = it->second; - rtl::OString rttiName; - toCppNames(name, &data.cppName, &rttiName); - data.info = new __Crun::static_type_info; - data.info->ty_name = data.cppName.getStr() - - reinterpret_cast< char * >(&data.info->ty_name); - data.info->reserved = 0; - NistHash hash(rttiName); - data.info->type_hash[0] = hash.hashdata[0]; - data.info->type_hash[1] = hash.hashdata[1]; - data.info->type_hash[2] = hash.hashdata[2]; - data.info->type_hash[3] = hash.hashdata[3]; - data.info->flags = 0; - data.info->cv_qualifiers = 0; - if (type->pBaseTypeDescription != NULL) { - data.bases = get_(type->pBaseTypeDescription).bases; - OSL_ASSERT(!data.bases.empty()); - data.bases.back().offset = 0; - } - __Crun::class_base_descr last; - last.type_hash[0] = data.info->type_hash[0]; - last.type_hash[1] = data.info->type_hash[1]; - last.type_hash[2] = data.info->type_hash[2]; - last.type_hash[3] = data.info->type_hash[3]; - last.offset = 0x8000000000000000; - data.bases.push_back(last); - data.info->base_table = reinterpret_cast< char * >(&data.bases[0]) - - reinterpret_cast< char * >(&data.info->base_table); - } - return it->second; -} - -void deleteException( - void * exception, unsigned int * thunk, typelib_TypeDescription * type) -{ - uno_destructData( - exception, type, - reinterpret_cast< uno_ReleaseFunc >(css::uno::cpp_release)); - typelib_typedescription_release(type); - delete[] thunk; -} - -} - -namespace bridges { namespace cpp_uno { namespace cc5_solaris_sparc64 { - -void raiseException(uno_Any * exception, uno_Mapping * unoToCpp) { - bridges::cpp_uno::shared::ArrayPointer< unsigned long > thunkPtr( - new unsigned long[4]); - typelib_TypeDescription * type = NULL; - typelib_typedescriptionreference_getDescription(&type, exception->pType); - __Crun::static_type_info const * rtti = RttiMap::get( - reinterpret_cast< typelib_CompoundTypeDescription * >(type)); - void * exc = __Crun::ex_alloc(type->nSize); - uno_copyAndConvertData(exc, exception->pData, type, unoToCpp); - uno_any_destruct(exception, NULL); - unsigned long * thunk = thunkPtr.release(); - // 0*4: rd %pc, %o1: - // 1*4: ldx %o1, (6-0)*4, %o3: - thunk[0] = 0x93414000D65A6018; - // 2*4: jmpl %o3, %g0, %g0: - // 3*4: ldx %o1, (4-0)*4, %o2: - thunk[1] = 0x81C2C000D45A6010; - // 4*4: .xword type: - thunk[2] = reinterpret_cast< unsigned long >(type); - // 6*4: .xword deleteException: - thunk[3] = reinterpret_cast< unsigned long >(deleteException); - flushCode(thunk, thunk + 4); - __Crun::ex_throw(exc, rtti, toFunction(thunk)); -} - -void fillUnoException( - void * cppException, char const * cppName, uno_Any * unoException, - uno_Mapping * cppToUno) -{ - OUString name; - typelib_TypeDescription * type = NULL; - if (toUnoName(cppName, &name)) { - typelib_typedescription_getByName(&type, name.pData); - } - if (type == NULL || type->eTypeClass != typelib_TypeClass_EXCEPTION) { - css::uno::RuntimeException exc( - "Not a UNO exception type: " + name, - css::uno::Reference< css::uno::XInterface >()); - uno_type_any_constructAndConvert( - unoException, &exc, getCppuType(&exc).getTypeLibType(), cppToUno); - } else { - uno_any_constructAndConvert(unoException, cppException, type, cppToUno); - } - if (type != NULL) { - typelib_typedescription_release(type); - } -} - -} } } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.hxx deleted file mode 100644 index da138964842f..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.hxx +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_EXCEPTIONS_HXX -#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_EXCEPTIONS_HXX - -#include "sal/config.h" - -#include <cstddef> - -#include "typelib/typedescription.h" -#include "uno/any2.h" -#include "uno/mapping.h" - -// Private CC5 structures and functions: -namespace __Crun { - struct class_base_descr { - int type_hash[4]; - std::size_t offset; - }; - struct static_type_info { - std::ptrdiff_t ty_name; - std::ptrdiff_t reserved; - std::ptrdiff_t base_table; - int type_hash[4]; - unsigned int flags; - unsigned int cv_qualifiers; - }; - void * ex_alloc(unsigned long); - void ex_throw(void *, static_type_info const *, void (*)(void *)); - void * ex_get(); - void ex_rethrow_q() throw (); -} -namespace __Cimpl { - char const * ex_name(); -} - -namespace bridges { namespace cpp_uno { namespace cc5_solaris_sparc64 { - -void raiseException(uno_Any * exception, uno_Mapping * unoToCpp); - -void fillUnoException( - void * cppException, char const * cppName, uno_Any * unoException, - uno_Mapping * cppToUno); - -} } } - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/flushcode.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/flushcode.hxx deleted file mode 100644 index be6a33d4ff55..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/flushcode.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_FLUSHCODE_HXX -#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_FLUSHCODE_HXX - -#include "sal/config.h" - -extern "C" void sync_instruction_memory(caddr_t addr, int len); // from libc - -namespace bridges { namespace cpp_uno { namespace cc5_solaris_sparc64 { - -/** - * Flush a region of memory into which code has been written dynamically. - */ -inline void flushCode(void const * begin, void const * end) { - sync_instruction_memory( - static_cast< caddr_t >(const_cast< void * >(begin)), - static_cast< char const * >(end) - static_cast< char const * >(begin)); -} - -} } } - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.hxx deleted file mode 100644 index 4adb3bc70077..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.hxx +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_FP_HXX -#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_FP_HXX - -#include "sal/config.h" - -extern "C" { - -void fp_loadf0(float *); -void fp_loadf1(float *); -void fp_loadf2(float *); -void fp_loadf3(float *); -void fp_loadf4(float *); -void fp_loadf5(float *); -void fp_loadf6(float *); -void fp_loadf7(float *); -void fp_loadf9(float *); -void fp_loadf11(float *); -void fp_loadf13(float *); -void fp_loadf15(float *); -void fp_loadf17(float *); -void fp_loadf19(float *); -void fp_loadf21(float *); -void fp_loadf23(float *); -void fp_loadf25(float *); -void fp_loadf27(float *); -void fp_loadf29(float *); -void fp_loadf31(float *); - -void fp_storef0(float *); -void fp_storef1(float *); -void fp_storef2(float *); -void fp_storef3(float *); -void fp_storef4(float *); -void fp_storef5(float *); -void fp_storef6(float *); -void fp_storef7(float *); -void fp_storef9(float *); -void fp_storef11(float *); -void fp_storef13(float *); -void fp_storef15(float *); -void fp_storef17(float *); -void fp_storef19(float *); -void fp_storef21(float *); -void fp_storef23(float *); -void fp_storef25(float *); -void fp_storef27(float *); -void fp_storef29(float *); -void fp_storef31(float *); - -void fp_loadd0(double *); -void fp_loadd2(double *); -void fp_loadd4(double *); -void fp_loadd6(double *); -void fp_loadd8(double *); -void fp_loadd10(double *); -void fp_loadd12(double *); -void fp_loadd14(double *); -void fp_loadd16(double *); -void fp_loadd18(double *); -void fp_loadd20(double *); -void fp_loadd22(double *); -void fp_loadd24(double *); -void fp_loadd26(double *); -void fp_loadd28(double *); -void fp_loadd30(double *); - -void fp_stored0(double *); -void fp_stored2(double *); -void fp_stored4(double *); -void fp_stored6(double *); -void fp_stored8(double *); -void fp_stored10(double *); -void fp_stored12(double *); -void fp_stored14(double *); -void fp_stored16(double *); -void fp_stored18(double *); -void fp_stored20(double *); -void fp_stored22(double *); -void fp_stored24(double *); -void fp_stored26(double *); -void fp_stored28(double *); -void fp_stored30(double *); - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.s b/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.s deleted file mode 100644 index 337ea4c2c34a..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.s +++ /dev/null @@ -1,593 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -.global fp_loadf0 -.align 8 -fp_loadf0: - retl - ld [%o0], %f0 -.size fp_loadf0, . - fp_loadf0 -.type fp_loadf0, #function - -.global fp_loadf1 -.align 8 -fp_loadf1: - retl - ld [%o0], %f1 -.size fp_loadf1, . - fp_loadf1 -.type fp_loadf1, #function - -.global fp_loadf2 -.align 8 -fp_loadf2: - retl - ld [%o0], %f2 -.size fp_loadf2, . - fp_loadf2 -.type fp_loadf2, #function - -.global fp_loadf3 -.align 8 -fp_loadf3: - retl - ld [%o0], %f3 -.size fp_loadf3, . - fp_loadf3 -.type fp_loadf3, #function - -.global fp_loadf4 -.align 8 -fp_loadf4: - retl - ld [%o0], %f4 -.size fp_loadf4, . - fp_loadf4 -.type fp_loadf4, #function - -.global fp_loadf5 -.align 8 -fp_loadf5: - retl - ld [%o0], %f5 -.size fp_loadf5, . - fp_loadf5 -.type fp_loadf5, #function - -.global fp_loadf6 -.align 8 -fp_loadf6: - retl - ld [%o0], %f6 -.size fp_loadf6, . - fp_loadf6 -.type fp_loadf6, #function - -.global fp_loadf7 -.align 8 -fp_loadf7: - retl - ld [%o0], %f7 -.size fp_loadf7, . - fp_loadf7 -.type fp_loadf7, #function - -.global fp_loadf9 -.align 8 -fp_loadf9: - retl - ld [%o0], %f9 -.size fp_loadf9, . - fp_loadf9 -.type fp_loadf9, #function - -.global fp_loadf11 -.align 8 -fp_loadf11: - retl - ld [%o0], %f11 -.size fp_loadf11, . - fp_loadf11 -.type fp_loadf11, #function - -.global fp_loadf13 -.align 8 -fp_loadf13: - retl - ld [%o0], %f13 -.size fp_loadf13, . - fp_loadf13 -.type fp_loadf13, #function - -.global fp_loadf15 -.align 8 -fp_loadf15: - retl - ld [%o0], %f15 -.size fp_loadf15, . - fp_loadf15 -.type fp_loadf15, #function - -.global fp_loadf17 -.align 8 -fp_loadf17: - retl - ld [%o0], %f17 -.size fp_loadf17, . - fp_loadf17 -.type fp_loadf17, #function - -.global fp_loadf19 -.align 8 -fp_loadf19: - retl - ld [%o0], %f19 -.size fp_loadf19, . - fp_loadf19 -.type fp_loadf19, #function - -.global fp_loadf21 -.align 8 -fp_loadf21: - retl - ld [%o0], %f21 -.size fp_loadf21, . - fp_loadf21 -.type fp_loadf21, #function - -.global fp_loadf23 -.align 8 -fp_loadf23: - retl - ld [%o0], %f23 -.size fp_loadf23, . - fp_loadf23 -.type fp_loadf23, #function - -.global fp_loadf25 -.align 8 -fp_loadf25: - retl - ld [%o0], %f25 -.size fp_loadf25, . - fp_loadf25 -.type fp_loadf25, #function - -.global fp_loadf27 -.align 8 -fp_loadf27: - retl - ld [%o0], %f27 -.size fp_loadf27, . - fp_loadf27 -.type fp_loadf27, #function - -.global fp_loadf29 -.align 8 -fp_loadf29: - retl - ld [%o0], %f29 -.size fp_loadf29, . - fp_loadf29 -.type fp_loadf29, #function - -.global fp_loadf31 -.align 8 -fp_loadf31: - retl - ld [%o0], %f31 -.size fp_loadf31, . - fp_loadf31 -.type fp_loadf31, #function - -.global fp_storef0 -.align 8 -fp_storef0: - retl - st %f0, [%o0] -.size fp_storef0, . - fp_storef0 -.type fp_storef0, #function - -.global fp_storef1 -.align 8 -fp_storef1: - retl - st %f1, [%o0] -.size fp_storef1, . - fp_storef1 -.type fp_storef1, #function - -.global fp_storef2 -.align 8 -fp_storef2: - retl - st %f2, [%o0] -.size fp_storef2, . - fp_storef2 -.type fp_storef2, #function - -.global fp_storef3 -.align 8 -fp_storef3: - retl - st %f3, [%o0] -.size fp_storef3, . - fp_storef3 -.type fp_storef3, #function - -.global fp_storef4 -.align 8 -fp_storef4: - retl - st %f4, [%o0] -.size fp_storef4, . - fp_storef4 -.type fp_storef4, #function - -.global fp_storef5 -.align 8 -fp_storef5: - retl - st %f5, [%o0] -.size fp_storef5, . - fp_storef5 -.type fp_storef5, #function - -.global fp_storef6 -.align 8 -fp_storef6: - retl - st %f6, [%o0] -.size fp_storef6, . - fp_storef6 -.type fp_storef6, #function - -.global fp_storef7 -.align 8 -fp_storef7: - retl - st %f7, [%o0] -.size fp_storef7, . - fp_storef7 -.type fp_storef7, #function - -.global fp_storef9 -.align 8 -fp_storef9: - retl - st %f9, [%o0] -.size fp_storef9, . - fp_storef9 -.type fp_storef9, #function - -.global fp_storef11 -.align 8 -fp_storef11: - retl - st %f11, [%o0] -.size fp_storef11, . - fp_storef11 -.type fp_storef11, #function - -.global fp_storef13 -.align 8 -fp_storef13: - retl - st %f13, [%o0] -.size fp_storef13, . - fp_storef13 -.type fp_storef13, #function - -.global fp_storef15 -.align 8 -fp_storef15: - retl - st %f15, [%o0] -.size fp_storef15, . - fp_storef15 -.type fp_storef15, #function - -.global fp_storef17 -.align 8 -fp_storef17: - retl - st %f17, [%o0] -.size fp_storef17, . - fp_storef17 -.type fp_storef17, #function - -.global fp_storef19 -.align 8 -fp_storef19: - retl - st %f19, [%o0] -.size fp_storef19, . - fp_storef19 -.type fp_storef19, #function - -.global fp_storef21 -.align 8 -fp_storef21: - retl - st %f21, [%o0] -.size fp_storef21, . - fp_storef21 -.type fp_storef21, #function - -.global fp_storef23 -.align 8 -fp_storef23: - retl - st %f23, [%o0] -.size fp_storef23, . - fp_storef23 -.type fp_storef23, #function - -.global fp_storef25 -.align 8 -fp_storef25: - retl - st %f25, [%o0] -.size fp_storef25, . - fp_storef25 -.type fp_storef25, #function - -.global fp_storef27 -.align 8 -fp_storef27: - retl - st %f27, [%o0] -.size fp_storef27, . - fp_storef27 -.type fp_storef27, #function - -.global fp_storef29 -.align 8 -fp_storef29: - retl - st %f29, [%o0] -.size fp_storef29, . - fp_storef29 -.type fp_storef29, #function - -.global fp_storef31 -.align 8 -fp_storef31: - retl - st %f31, [%o0] -.size fp_storef31, . - fp_storef31 -.type fp_storef31, #function - -.global fp_loadd0 -.align 8 -fp_loadd0: - retl - ldd [%o0], %f0 -.size fp_loadd0, . - fp_loadd0 -.type fp_loadd0, #function - -.global fp_loadd2 -.align 8 -fp_loadd2: - retl - ldd [%o0], %f2 -.size fp_loadd2, . - fp_loadd2 -.type fp_loadd2, #function - -.global fp_loadd4 -.align 8 -fp_loadd4: - retl - ldd [%o0], %f4 -.size fp_loadd4, . - fp_loadd4 -.type fp_loadd4, #function - -.global fp_loadd6 -.align 8 -fp_loadd6: - retl - ldd [%o0], %f6 -.size fp_loadd6, . - fp_loadd6 -.type fp_loadd6, #function - -.global fp_loadd8 -.align 8 -fp_loadd8: - retl - ldd [%o0], %f8 -.size fp_loadd8, . - fp_loadd8 -.type fp_loadd8, #function - -.global fp_loadd10 -.align 8 -fp_loadd10: - retl - ldd [%o0], %f10 -.size fp_loadd10, . - fp_loadd10 -.type fp_loadd10, #function - -.global fp_loadd12 -.align 8 -fp_loadd12: - retl - ldd [%o0], %f12 -.size fp_loadd12, . - fp_loadd12 -.type fp_loadd12, #function - -.global fp_loadd14 -.align 8 -fp_loadd14: - retl - ldd [%o0], %f14 -.size fp_loadd14, . - fp_loadd14 -.type fp_loadd14, #function - -.global fp_loadd16 -.align 8 -fp_loadd16: - retl - ldd [%o0], %f16 -.size fp_loadd16, . - fp_loadd16 -.type fp_loadd16, #function - -.global fp_loadd18 -.align 8 -fp_loadd18: - retl - ldd [%o0], %f18 -.size fp_loadd18, . - fp_loadd18 -.type fp_loadd18, #function - -.global fp_loadd20 -.align 8 -fp_loadd20: - retl - ldd [%o0], %f20 -.size fp_loadd20, . - fp_loadd20 -.type fp_loadd20, #function - -.global fp_loadd22 -.align 8 -fp_loadd22: - retl - ldd [%o0], %f22 -.size fp_loadd22, . - fp_loadd22 -.type fp_loadd22, #function - -.global fp_loadd24 -.align 8 -fp_loadd24: - retl - ldd [%o0], %f24 -.size fp_loadd24, . - fp_loadd24 -.type fp_loadd24, #function - -.global fp_loadd26 -.align 8 -fp_loadd26: - retl - ldd [%o0], %f26 -.size fp_loadd26, . - fp_loadd26 -.type fp_loadd26, #function - -.global fp_loadd28 -.align 8 -fp_loadd28: - retl - ldd [%o0], %f28 -.size fp_loadd28, . - fp_loadd28 -.type fp_loadd28, #function - -.global fp_loadd30 -.align 8 -fp_loadd30: - retl - ldd [%o0], %f30 -.size fp_loadd30, . - fp_loadd30 -.type fp_loadd30, #function - -.global fp_stored0 -.align 8 -fp_stored0: - retl - std %f0, [%o0] -.size fp_stored0, . - fp_stored0 -.type fp_stored0, #function - -.global fp_stored2 -.align 8 -fp_stored2: - retl - std %f2, [%o0] -.size fp_stored2, . - fp_stored2 -.type fp_stored2, #function - -.global fp_stored4 -.align 8 -fp_stored4: - retl - std %f4, [%o0] -.size fp_stored4, . - fp_stored4 -.type fp_stored4, #function - -.global fp_stored6 -.align 8 -fp_stored6: - retl - std %f6, [%o0] -.size fp_stored6, . - fp_stored6 -.type fp_stored6, #function - -.global fp_stored8 -.align 8 -fp_stored8: - retl - std %f8, [%o0] -.size fp_stored8, . - fp_stored8 -.type fp_stored8, #function - -.global fp_stored10 -.align 8 -fp_stored10: - retl - std %f10, [%o0] -.size fp_stored10, . - fp_stored10 -.type fp_stored10, #function - -.global fp_stored12 -.align 8 -fp_stored12: - retl - std %f12, [%o0] -.size fp_stored12, . - fp_stored12 -.type fp_stored12, #function - -.global fp_stored14 -.align 8 -fp_stored14: - retl - std %f14, [%o0] -.size fp_stored14, . - fp_stored14 -.type fp_stored14, #function - -.global fp_stored16 -.align 8 -fp_stored16: - retl - std %f16, [%o0] -.size fp_stored16, . - fp_stored16 -.type fp_stored16, #function - -.global fp_stored18 -.align 8 -fp_stored18: - retl - std %f18, [%o0] -.size fp_stored18, . - fp_stored18 -.type fp_stored18, #function - -.global fp_stored20 -.align 8 -fp_stored20: - retl - std %f20, [%o0] -.size fp_stored20, . - fp_stored20 -.type fp_stored20, #function - -.global fp_stored22 -.align 8 -fp_stored22: - retl - std %f22, [%o0] -.size fp_stored22, . - fp_stored22 -.type fp_stored22, #function - -.global fp_stored24 -.align 8 -fp_stored24: - retl - std %f24, [%o0] -.size fp_stored24, . - fp_stored24 -.type fp_stored24, #function - -.global fp_stored26 -.align 8 -fp_stored26: - retl - std %f26, [%o0] -.size fp_stored26, . - fp_stored26 -.type fp_stored26, #function - -.global fp_stored28 -.align 8 -fp_stored28: - retl - std %f28, [%o0] -.size fp_stored28, . - fp_stored28 -.type fp_stored28, #function - -.global fp_stored30 -.align 8 -fp_stored30: - retl - std %f30, [%o0] -.size fp_stored30, . - fp_stored30 -.type fp_stored30, #function diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/isdirectreturntype.cxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/isdirectreturntype.cxx deleted file mode 100644 index 5afd8c1006e0..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/isdirectreturntype.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "sal/config.h" - -#include <cstddef> - -#include "sal/types.h" -#include "typelib/typeclass.h" -#include "typelib/typedescription.h" - -#include "isdirectreturntype.hxx" - -namespace { - -bool isPodStruct(typelib_CompoundTypeDescription * type) { - for (; type != NULL; type = type->pBaseTypeDescription) { - for (sal_Int32 i = 0; i < type->nMembers; ++i) { - if (!bridges::cpp_uno::cc5_solaris_sparc64::isDirectReturnType( - type->ppTypeRefs[i])) - { - return false; - } - } - } - return true; -} - -} - -namespace bridges { namespace cpp_uno { namespace cc5_solaris_sparc64 { - -bool isDirectReturnType(typelib_TypeDescriptionReference * type) { - // Is POD of size <= 32 bytes: - switch (type->eTypeClass) { - default: - return true; - case typelib_TypeClass_STRING: - case typelib_TypeClass_TYPE: - case typelib_TypeClass_ANY: - case typelib_TypeClass_SEQUENCE: - case typelib_TypeClass_INTERFACE: - return false; - case typelib_TypeClass_STRUCT: - { - typelib_TypeDescription * t = NULL; - TYPELIB_DANGER_GET(&t, type); - bool b = t->nSize <= 32 && isPodStruct( - reinterpret_cast< typelib_CompoundTypeDescription * >(t)); - TYPELIB_DANGER_RELEASE(t); - return b; - } - } -} - -} } } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/isdirectreturntype.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/isdirectreturntype.hxx deleted file mode 100644 index 66be5cd629af..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/isdirectreturntype.hxx +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_ISDIRECTRETURNTYPE_x -#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_ISDIRECTRETURNTYPE_x - -#include "sal/config.h" - -#include "typelib/typedescription.h" - -namespace bridges { namespace cpp_uno { namespace cc5_solaris_sparc64 { - -bool isDirectReturnType(typelib_TypeDescriptionReference * type); - -} } } - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/uno2cpp.cxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/uno2cpp.cxx deleted file mode 100644 index b91f2ab0806d..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/uno2cpp.cxx +++ /dev/null @@ -1,500 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "sal/config.h" - -#include <algorithm> -#include <cstddef> -#include <cstring> - -#include "bridges/cpp_uno/shared/bridge.hxx" -#include "bridges/cpp_uno/shared/types.hxx" -#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx" -#include "bridges/cpp_uno/shared/vtables.hxx" -#include "com/sun/star/uno/Exception.hpp" -#include "com/sun/star/uno/genfunc.hxx" -#include "osl/diagnose.h" -#include "rtl/ustring.h" -#include "rtl/ustring.hxx" -#include "sal/alloca.h" -#include "sal/types.h" -#include "typelib/typeclass.h" -#include "typelib/typedescription.h" -#include "uno/any2.h" -#include "uno/data.h" - -#include "callvirtualmethod.hxx" -#include "exceptions.hxx" -#include "fp.hxx" -#include "isdirectreturntype.hxx" - -namespace { - -void storeFpRegsToStruct(typelib_TypeDescription * type, void * data) { - for (typelib_CompoundTypeDescription * t = - reinterpret_cast< typelib_CompoundTypeDescription * >(type); - t != NULL; t = t->pBaseTypeDescription) - { - for (sal_Int32 i = 0; i < t->nMembers; ++i) { - switch (t->ppTypeRefs[i]->eTypeClass) { - case typelib_TypeClass_FLOAT: - switch (t->pMemberOffsets[i]) { - case 0: - fp_storef0(reinterpret_cast< float * >(data)); - break; - case 4: - fp_storef1(reinterpret_cast< float * >(data) + 1); - break; - case 8: - fp_storef2(reinterpret_cast< float * >(data) + 2); - break; - case 12: - fp_storef3(reinterpret_cast< float * >(data) + 3); - break; - case 16: - fp_storef4(reinterpret_cast< float * >(data) + 4); - break; - case 20: - fp_storef5(reinterpret_cast< float * >(data) + 5); - break; - case 24: - fp_storef6(reinterpret_cast< float * >(data) + 6); - break; - case 28: - fp_storef7(reinterpret_cast< float * >(data) + 7); - break; - default: - OSL_ASSERT(false); - break; - } - break; - case typelib_TypeClass_DOUBLE: - switch (t->pMemberOffsets[i]) { - case 0: - fp_stored0(reinterpret_cast< double * >(data)); - break; - case 8: - fp_stored2(reinterpret_cast< double * >(data) + 1); - break; - case 16: - fp_stored4(reinterpret_cast< double * >(data) + 2); - break; - case 24: - fp_stored6(reinterpret_cast< double * >(data) + 3); - break; - default: - OSL_ASSERT(false); - break; - } - break; - case typelib_TypeClass_STRUCT: - { - typelib_TypeDescription * td = NULL; - TYPELIB_DANGER_GET(&td, t->ppTypeRefs[i]); - storeFpRegsToStruct(td, data); - TYPELIB_DANGER_RELEASE(td); - break; - } - } - } - } -} - -void call( - bridges::cpp_uno::shared::UnoInterfaceProxy * proxy, - bridges::cpp_uno::shared::VtableSlot slot, - typelib_TypeDescriptionReference * returnType, sal_Int32 count, - typelib_MethodParameter * parameters, void * returnValue, void ** arguments, - uno_Any ** exception) -{ - bool directRet = bridges::cpp_uno::cc5_solaris_sparc64::isDirectReturnType( - returnType); - long * stack = static_cast< long * >( - alloca( - std::max< sal_Int32 >(count + (directRet ? 1 : 2), 4) * - sizeof (long))); - sal_Int32 sp = 0; - typelib_TypeDescription * rtd = NULL; - TYPELIB_DANGER_GET(&rtd, returnType); - bool retconv = bridges::cpp_uno::shared::relatesToInterfaceType(rtd); - OSL_ASSERT(!(directRet && retconv)); - void * ret; - if (!directRet) { - ret = retconv ? alloca(rtd->nSize) : returnValue; - stack[sp++] = reinterpret_cast< long >(ret); - } - unsigned long ** thisPtr = reinterpret_cast< unsigned long ** >( - proxy->getCppI()) + slot.offset; - stack[sp++] = reinterpret_cast< long >(thisPtr); - void ** cppArgs = static_cast< void ** >(alloca(count * sizeof (void *))); - typelib_TypeDescription ** ptds = - static_cast< typelib_TypeDescription ** >( - alloca(count * sizeof (typelib_TypeDescription *))); - for (sal_Int32 i = 0; i < count; ++i) { - if (!parameters[i].bOut && - bridges::cpp_uno::shared::isSimpleType(parameters[i].pTypeRef)) - { - cppArgs[i] = NULL; - switch (parameters[i].pTypeRef->eTypeClass) { - case typelib_TypeClass_BOOLEAN: - stack[sp] = *static_cast< sal_Bool * >(arguments[i]); - break; - case typelib_TypeClass_BYTE: - stack[sp] = *static_cast< sal_Int8 * >(arguments[i]); - break; - case typelib_TypeClass_SHORT: - stack[sp] = *static_cast< sal_Int16 * >(arguments[i]); - break; - case typelib_TypeClass_UNSIGNED_SHORT: - stack[sp] = *static_cast< sal_uInt16 * >(arguments[i]); - break; - case typelib_TypeClass_LONG: - case typelib_TypeClass_ENUM: - stack[sp] = *static_cast< sal_Int32 * >(arguments[i]); - break; - case typelib_TypeClass_UNSIGNED_LONG: - stack[sp] = *static_cast< sal_uInt32 * >(arguments[i]); - break; - case typelib_TypeClass_HYPER: - stack[sp] = *static_cast< sal_Int64 * >(arguments[i]); - break; - case typelib_TypeClass_UNSIGNED_HYPER: - stack[sp] = *static_cast< sal_uInt64 * >(arguments[i]); - break; - case typelib_TypeClass_FLOAT: - { - float * f = static_cast< float * >(arguments[i]); - switch (sp) { - case 1: - fp_loadf3(f); - break; - case 2: - fp_loadf5(f); - break; - case 3: - fp_loadf7(f); - break; - case 4: - fp_loadf9(f); - break; - case 5: - fp_loadf11(f); - break; - case 6: - fp_loadf13(f); - break; - case 7: - fp_loadf15(f); - break; - case 8: - fp_loadf17(f); - break; - case 9: - fp_loadf19(f); - break; - case 10: - fp_loadf21(f); - break; - case 11: - fp_loadf23(f); - break; - case 12: - fp_loadf25(f); - break; - case 13: - fp_loadf27(f); - break; - case 14: - fp_loadf29(f); - break; - case 15: - fp_loadf31(f); - break; - default: - reinterpret_cast< float * >(stack + sp)[1] = *f; - break; - } - break; - } - case typelib_TypeClass_DOUBLE: - { - double * d = static_cast< double * >(arguments[i]); - switch (sp) { - case 1: - fp_loadd2(d); - break; - case 2: - fp_loadd4(d); - break; - case 3: - fp_loadd6(d); - break; - case 4: - fp_loadd8(d); - break; - case 5: - fp_loadd10(d); - break; - case 6: - fp_loadd12(d); - break; - case 7: - fp_loadd14(d); - break; - case 8: - fp_loadd16(d); - break; - case 9: - fp_loadd18(d); - break; - case 10: - fp_loadd20(d); - break; - case 11: - fp_loadd22(d); - break; - case 12: - fp_loadd24(d); - break; - case 13: - fp_loadd26(d); - break; - case 14: - fp_loadd28(d); - break; - case 15: - fp_loadd30(d); - break; - default: - *reinterpret_cast< double * >(stack + sp) = *d; - break; - } - break; - } - case typelib_TypeClass_CHAR: - stack[sp] = *static_cast< sal_Unicode * >(arguments[i]); - break; - default: - OSL_ASSERT(false); - break; - } - } else { - typelib_TypeDescription * ptd = NULL; - TYPELIB_DANGER_GET(&ptd, parameters[i].pTypeRef); - if (!parameters[i].bIn) { - cppArgs[i] = alloca(ptd->nSize); - uno_constructData(cppArgs[i], ptd); - ptds[i] = ptd; - *reinterpret_cast< void ** >(stack + sp) = cppArgs[i]; - } else if (bridges::cpp_uno::shared::relatesToInterfaceType(ptd)) { - cppArgs[i] = alloca(ptd->nSize); - uno_copyAndConvertData( - cppArgs[i], arguments[i], ptd, - proxy->getBridge()->getUno2Cpp()); - ptds[i] = ptd; - *reinterpret_cast< void ** >(stack + sp) = cppArgs[i]; - } else { - cppArgs[i] = NULL; - *reinterpret_cast< void ** >(stack + sp) = arguments[i]; - TYPELIB_DANGER_RELEASE(ptd); - } - } - ++sp; - } - try { - callVirtualMethod( - (*thisPtr)[slot.index + 2], stack, - std::max< sal_Int32 >(sp - 6, 0) * sizeof (long)); - } catch (const css::uno::Exception &) { - void * exc = __Crun::ex_get(); - char const * name = __Cimpl::ex_name(); - bridges::cpp_uno::cc5_solaris_sparc64::fillUnoException( - exc, name, *exception, proxy->getBridge()->getCpp2Uno()); - for (sal_Int32 i = 0; i < count; ++i) { - if (cppArgs[i] != NULL) { - uno_destructData( - cppArgs[i], ptds[i], - reinterpret_cast< uno_ReleaseFunc >(css::uno::cpp_release)); - TYPELIB_DANGER_RELEASE(ptds[i]); - } - } - TYPELIB_DANGER_RELEASE(rtd); - return; - } - *exception = NULL; - for (sal_Int32 i = 0; i < count; ++i) { - if (cppArgs[i] != NULL) { - if (parameters[i].bOut) { - if (parameters[i].bIn) { - uno_destructData(arguments[i], ptds[i], NULL); - } - uno_copyAndConvertData( - arguments[i], cppArgs[i], ptds[i], - proxy->getBridge()->getCpp2Uno()); - } - uno_destructData( - cppArgs[i], ptds[i], - reinterpret_cast< uno_ReleaseFunc >(css::uno::cpp_release)); - TYPELIB_DANGER_RELEASE(ptds[i]); - } - } - if (directRet) { - switch (rtd->eTypeClass) { - case typelib_TypeClass_FLOAT: - fp_storef0(reinterpret_cast< float * >(returnValue)); - break; - case typelib_TypeClass_DOUBLE: - fp_stored0(reinterpret_cast< double * >(returnValue)); - break; - case typelib_TypeClass_STRUCT: - storeFpRegsToStruct(rtd, stack); - // fall through - case typelib_TypeClass_ANY: - std::memcpy(returnValue, stack, rtd->nSize); - break; - default: - OSL_ASSERT(rtd->nSize <= 8); - std::memcpy( - returnValue, - reinterpret_cast< char * >(stack) + (8 - rtd->nSize), - rtd->nSize); - break; - } - } else if (retconv) { - uno_copyAndConvertData( - returnValue, ret, rtd, proxy->getBridge()->getCpp2Uno()); - uno_destructData( - ret, rtd, - reinterpret_cast< uno_ReleaseFunc >(css::uno::cpp_release)); - } - TYPELIB_DANGER_RELEASE(rtd); -} - -} - -namespace bridges { namespace cpp_uno { namespace shared { - -void unoInterfaceProxyDispatch( - uno_Interface * pUnoI, typelib_TypeDescription const * pMemberDescr, - void * pReturn, void * pArgs[], uno_Any ** ppException) -{ - bridges::cpp_uno::shared::UnoInterfaceProxy * proxy = - static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI); - switch (pMemberDescr->eTypeClass) { - case typelib_TypeClass_INTERFACE_ATTRIBUTE: - { - VtableSlot slot( - getVtableSlot( - reinterpret_cast< - typelib_InterfaceAttributeTypeDescription const * >( - pMemberDescr))); - if (pReturn != NULL) { - // Getter: - call( - proxy, slot, - (reinterpret_cast< - typelib_InterfaceAttributeTypeDescription const * >( - pMemberDescr)->pAttributeTypeRef), - 0, NULL, pReturn, pArgs, ppException); - } else { - // Setter: - OUString aVoid = "void"; - typelib_MethodParameter param = { - NULL, - (reinterpret_cast< - typelib_InterfaceAttributeTypeDescription const * >( - pMemberDescr)->pAttributeTypeRef), - true, false }; - typelib_TypeDescriptionReference * rtd = NULL; - typelib_typedescriptionreference_new( - &rtd, typelib_TypeClass_VOID, aVoid.pData); - slot.index += 1; - call(proxy, slot, rtd, 1, ¶m, pReturn, pArgs, ppException); - typelib_typedescriptionreference_release(rtd); - } - break; - } - case typelib_TypeClass_INTERFACE_METHOD: - { - VtableSlot slot( - getVtableSlot( - reinterpret_cast< - typelib_InterfaceMethodTypeDescription const * >( - pMemberDescr))); - switch (slot.index) { - case 1: - pUnoI->acquire(pUnoI); - *ppException = NULL; - break; - case 2: - pUnoI->release(pUnoI); - *ppException = NULL; - break; - case 0: - { - typelib_TypeDescription * td = NULL; - TYPELIB_DANGER_GET( - &td, - reinterpret_cast< css::uno::Type * >( - pArgs[0])->getTypeLibType()); - if (td != NULL) { - uno_Interface * ifc = NULL; - proxy->pBridge->getUnoEnv()->getRegisteredInterface( - proxy->pBridge->getUnoEnv(), - reinterpret_cast< void ** >(&ifc), - proxy->oid.pData, - (reinterpret_cast< - typelib_InterfaceTypeDescription * >(td))); - if (ifc != NULL) { - uno_any_construct( - reinterpret_cast< uno_Any * >(pReturn), - &ifc, td, NULL); - ifc->release(ifc); - TYPELIB_DANGER_RELEASE(td); - *ppException = NULL; - break; - } - TYPELIB_DANGER_RELEASE(td); - } - } // fall through - default: - call( - proxy, slot, - (reinterpret_cast< - typelib_InterfaceMethodTypeDescription const * >( - pMemberDescr)->pReturnTypeRef), - (reinterpret_cast< - typelib_InterfaceMethodTypeDescription const * >( - pMemberDescr)->nParams), - (reinterpret_cast< - typelib_InterfaceMethodTypeDescription const * >( - pMemberDescr)->pParams), - pReturn, pArgs, ppException); - } - break; - } - default: - OSL_ASSERT(false); - break; - } -} - -} } } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.hxx deleted file mode 100644 index c7e27af89b2a..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.hxx +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_VTABLESLOTCALL_HXX -#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_CC5_SOLARIS_SPARC64_VTABLESLOTCALL_HXX - -#include "sal/config.h" - -extern "C" void vtableSlotCall(); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.s b/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.s deleted file mode 100644 index 3e187e2d7297..000000000000 --- a/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.s +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -.global vtableCall - -.global vtableSlotCall -.align 8 -vtableSlotCall: - ! save %sp, -176, %sp already done in code snippet - stx %i0, [%fp + 2047 + 128] - stx %i1, [%fp + 2047 + 136] - stx %i2, [%fp + 2047 + 144] - stx %i3, [%fp + 2047 + 152] - stx %i4, [%fp + 2047 + 160] - stx %i5, [%fp + 2047 + 168] - ! %o0: functionIndex, stored by code snippet - ! %o1: vtableOffset, stored by code snippet - call vtableCall - add %fp, 2047 + 128, %o2 - ldx [%fp + 2047 + 128], %i0 - ldx [%fp + 2047 + 136], %i1 - ldx [%fp + 2047 + 144], %i2 - ldx [%fp + 2047 + 152], %i3 - ret - restore -.size vtableSlotCall, . - vtableSlotCall -.type vtableSlotCall, #function |