diff options
Diffstat (limited to 'bridges/source/cpp_uno/cc5_solaris_sparc64')
14 files changed, 2778 insertions, 0 deletions
diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.hxx new file mode 100644 index 000000000000..889df40a5b40 --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.hxx @@ -0,0 +1,36 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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 diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.s b/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.s new file mode 100644 index 000000000000..67c5aa39ade5 --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/callvirtualmethod.s @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +.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 new file mode 100644 index 000000000000..19be97baf7fa --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/cpp2uno.cxx @@ -0,0 +1,611 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_bridges.hxx" +#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 { + +namespace css = com::sun::star; + +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); +} diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.cxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.cxx new file mode 100644 index 000000000000..020cdea27333 --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.cxx @@ -0,0 +1,459 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_bridges.hxx" +#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 { + +namespace css = com::sun::star; + +typedef void (* Function)(void *); + +Function toFunction(void * pointer) { +#pragma disable_warn + return reinterpret_cast< Function >(pointer); +#pragma enable_warn +} + +bool toUnoName(char const * rttiName, rtl::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< rtl::OUString, Data > Map; + + static void toCppNames( + rtl::OUString const & unoName, rtl::OString * cppName, + rtl::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( + rtl::OUString const & unoName, rtl::OString * cppName, + rtl::OString * rttiName) +{ + OSL_ASSERT(cppName != NULL && rttiName != NULL); + rtl::OStringBuffer bc; + rtl::OStringBuffer br; + br.append("__1n"); + for (sal_Int32 i = 0; i != -1;) { + rtl::OUString tok(unoName.getToken(0, '.', i)); + bc.append(rtl::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) +{ + rtl::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) +{ + rtl::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( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("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); + } +} + +} } } diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.hxx new file mode 100644 index 000000000000..7a0963bc695d --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/exceptions.hxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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 diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/flushcode.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/flushcode.hxx new file mode 100644 index 000000000000..bdce67c4da89 --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/flushcode.hxx @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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 diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.hxx new file mode 100644 index 000000000000..84bdbc74bf15 --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.hxx @@ -0,0 +1,113 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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 diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.s b/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.s new file mode 100644 index 000000000000..92216d4e08dd --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/fp.s @@ -0,0 +1,602 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +.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 new file mode 100644 index 000000000000..f2af8103417c --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/isdirectreturntype.cxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_bridges.hxx" +#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; + } + } +} + +} } } diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/isdirectreturntype.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/isdirectreturntype.hxx new file mode 100644 index 000000000000..a5c182cf7985 --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/isdirectreturntype.hxx @@ -0,0 +1,41 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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 diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/makefile.mk b/bridges/source/cpp_uno/cc5_solaris_sparc64/makefile.mk new file mode 100644 index 000000000000..ec64b1db49dd --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/makefile.mk @@ -0,0 +1,61 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ := ..$/..$/.. +PRJNAME := bridges +TARGET := sunpro5_uno +ENABLE_EXCEPTIONS := TRUE + +.INCLUDE: settings.mk + +.IF "$(COM)" == "C52" && "$(CPU)" == "U" + +SHL1TARGET = $(TARGET) +SHL1OBJS = \ + $(SLO)$/callvirtualmethod.obj \ + $(SLO)$/cpp2uno.obj \ + $(SLO)$/exceptions.obj \ + $(SLO)$/fp.obj \ + $(SLO)$/isdirectreturntype.obj \ + $(SLO)$/uno2cpp.obj \ + $(SLO)$/vtableslotcall.obj +SHL1LIBS = $(SLB)$/cpp_uno_shared.lib +SHL1STDLIBS = $(CPPULIB) $(SALLIB) +SHL1RPATH = URELIB +SHL1VERSIONMAP = ..$/..$/bridge_exports.map +SHL1IMPLIB= i$(SHL1TARGET) +DEF1NAME = $(SHL1TARGET) + +SLOFILES = $(SHL1OBJS) + +.ENDIF + +.INCLUDE: target.mk + +$(SLO)$/%.obj: %.s + CC -m64 -KPIC -c -o $(SLO)$/$(@:b).o $< + touch $@ diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/uno2cpp.cxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/uno2cpp.cxx new file mode 100644 index 000000000000..05733f2bd9ed --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/uno2cpp.cxx @@ -0,0 +1,509 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_bridges.hxx" +#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 { + +namespace css = com::sun::star; + +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 (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: + typelib_MethodParameter param = { + NULL, + (reinterpret_cast< + typelib_InterfaceAttributeTypeDescription const * >( + pMemberDescr)->pAttributeTypeRef), + true, false }; + typelib_TypeDescriptionReference * rtd = NULL; + typelib_typedescriptionreference_new( + &rtd, typelib_TypeClass_VOID, + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("void")).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; + } +} + +} } } diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.hxx b/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.hxx new file mode 100644 index 000000000000..9ccc4a517f82 --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.hxx @@ -0,0 +1,35 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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 diff --git a/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.s b/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.s new file mode 100644 index 000000000000..01a22da74fff --- /dev/null +++ b/bridges/source/cpp_uno/cc5_solaris_sparc64/vtableslotcall.s @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +.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 |