LibreOffice Module bridges (master) 1
gcc3_linux_riscv64/abi.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#include <com/sun/star/uno/genfunc.hxx>
11#include <uno/data.h>
12#include <typelib/typedescription.hxx>
13#include "types.hxx"
14#include "abi.hxx"
15#include <stdio.h>
16#include <cstring>
17
18//#define BRIDGE_DEBUG
19
20namespace abi_riscv64
21{
22void countnGreg(sal_Int32& nGreg, sal_Int32& nFreg,
23 const typelib_CompoundTypeDescription* pTypeDescr)
24{
25 for (int i = 0; i < pTypeDescr->nMembers; i++)
26 {
27 typelib_TypeDescriptionReference* pTypeInStruct = pTypeDescr->ppTypeRefs[i];
28 switch (pTypeInStruct->eTypeClass)
29 {
30 case typelib_TypeClass_STRUCT:
31 case typelib_TypeClass_EXCEPTION:
32 {
33 typelib_TypeDescription* childTypeDescr = nullptr;
34 TYPELIB_DANGER_GET(&childTypeDescr, pTypeInStruct);
36 nGreg, nFreg,
37 reinterpret_cast<typelib_CompoundTypeDescription const*>(childTypeDescr));
38 TYPELIB_DANGER_RELEASE(childTypeDescr);
39 }
40 break;
41 case typelib_TypeClass_FLOAT:
42 case typelib_TypeClass_DOUBLE:
43 nFreg++;
44 break;
45 default:
46 nGreg++;
47 break;
48 }
49 }
50}
51
52void fillStruct(const typelib_TypeDescription* pTypeDescr, sal_Int64* gret, double* fret,
53 void* pRegisterReturn)
54{
55#ifdef BRIDGE_DEBUG
56 printf("In fillStruct, pTypeDescr = %p, gret = %p, fret = %p, pRegisterReturn = %p\n",
57 pTypeDescr, gret, fret, pRegisterReturn);
58#endif
59 sal_Int32 nGreg = 0;
60 sal_Int32 nFreg = 0;
61 countnGreg(nGreg, nFreg, reinterpret_cast<typelib_CompoundTypeDescription const*>(pTypeDescr));
62 char* pAdjust = reinterpret_cast<char*>(pRegisterReturn);
63 if (nGreg == 0 && nFreg <= 2)
64 {
65 if (pTypeDescr->nSize <= 8 && nFreg == 2)
66 {
67 std::memcpy(pAdjust, fret, 4);
68 std::memcpy(pAdjust + 4, fret + 1, 4);
69 }
70 else
71 {
72 std::memcpy(pAdjust, fret, 16);
73 }
74 }
75 else if (nFreg == 1 && nGreg == 1)
76 {
77 if (pTypeDescr->nSize > 8)
78 {
79 std::memcpy(pAdjust, gret, 8);
80 std::memcpy(pAdjust + 8, fret, 8);
81 }
82 else
83 {
84 std::memcpy(pAdjust, gret, 4);
85 std::memcpy(pAdjust + 4, fret, 4);
86 }
87 }
88 else
89 {
90 std::memcpy(pAdjust, gret, 16);
91 }
92}
93}
94
95/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
struct _typelib_TypeDescription typelib_TypeDescription
Definition: msvc/except.hxx:53
void countnGreg(sal_Int32 &nGreg, sal_Int32 &nFreg, const typelib_CompoundTypeDescription *pTypeDescr)
void fillStruct(const typelib_TypeDescription *pTypeDescr, sal_Int64 *gret, double *fret, void *pRegisterReturn)
int i