View | Details | Raw Unified | Return to bug 215130
Collapse All | Expand All

(-)Makefile (-1 / +4 lines)
Lines 118-124 Link Here
118
XDGREL=			../../${INSTALLATION_BASEDIR}/openoffice${AOOVERSION1}/share/xdg
116
XDGREL=			../../${INSTALLATION_BASEDIR}/openoffice${AOOVERSION1}/share/xdg
119
EXECBASE?=		openoffice-${AOOSUFFIX}
117
EXECBASE?=		openoffice-${AOOSUFFIX}
120
118
121
ONLY_FOR_ARCHS=	i386 amd64
119
ONLY_FOR_ARCHS=	i386 amd64 powerpc64
122
120
123
USE_GL=		gl glu
121
USE_GL=		gl glu
124
USE_GNOME=	gtk20 libxslt libidl glib20
122
USE_GNOME=	gtk20 libxslt libidl glib20
Lines 187-192 Link Here
187
.else
185
.else
188
FREEBSD_ENV_SET=	FreeBSDX86Env.Set.sh
186
FREEBSD_ENV_SET=	FreeBSDX86Env.Set.sh
189
PACKAGE_MIDDLE=		${PORTVERSION}_${OPSYS}_x86
187
PACKAGE_MIDDLE=		${PORTVERSION}_${OPSYS}_x86
188
.endif
189
.if ${ARCH} == powerpc64
190
FREEBSD_ENV_SET=	FreeBSDPPC64Env.Set.sh
190
.endif
191
.endif
191
PACKAGE_PREFIX=		Apache_OpenOffice
192
PACKAGE_PREFIX=		Apache_OpenOffice
(-)files/patch-openoffice4_powerpc64 (+3967 lines)
Added Link Here
1
--- bridges/prj/build.lst.orig
2
+++ bridges/prj/build.lst
3
@@ -9,6 +9,8 @@
4
 br	bridges\source\cpp_uno\gcc3_freebsd_intel	nmake	-	u	br_gcc3fi br_cppuno_shared br_unotypes br_inc NULL
5
 br	bridges\source\cpp_uno\gcc3_linux_x86-64	nmake	-	u	br_gcc3lx br_cppuno_shared br_unotypes br_inc NULL
6
 br	bridges\source\cpp_uno\gcc3_freebsd_x86-64	nmake	-	u	br_gcc3fx br_cppuno_shared br_unotypes br_inc NULL
7
+br	bridges\source\cpp_uno\gcc3_freebsd_powerpc	nmake	-	u	br_gcc3fp br_cppuno_shared br_unotypes br_inc NULL
8
+br	bridges\source\cpp_uno\gcc3_freebsd_powerpc64	nmake	-	u	br_gcc3fp_64 br_cppuno_shared br_unotypes br_inc NULL
9
 br	bridges\source\cpp_uno\gcc3_linux_powerpc	nmake	-	u	br_gcc3lp br_cppuno_shared br_unotypes br_inc NULL
10
 br	bridges\source\cpp_uno\gcc3_linux_powerpc64	nmake	-	u	br_gcc3lp_64 br_cppuno_shared br_unotypes br_inc NULL
11
 br	bridges\source\cpp_uno\gcc3_linux_mips		nmake	-	u	br_gcc3lmips br_cppuno_shared br_unotypes br_inc NULL
12
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
13
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc/cpp2uno.cxx
14
@@ -0,0 +1,791 @@
15
+/**************************************************************
16
+ * 
17
+ * Licensed to the Apache Software Foundation (ASF) under one
18
+ * or more contributor license agreements.  See the NOTICE file
19
+ * distributed with this work for additional information
20
+ * regarding copyright ownership.  The ASF licenses this file
21
+ * to you under the Apache License, Version 2.0 (the
22
+ * "License"); you may not use this file except in compliance
23
+ * with the License.  You may obtain a copy of the License at
24
+ * 
25
+ *   http://www.apache.org/licenses/LICENSE-2.0
26
+ * 
27
+ * Unless required by applicable law or agreed to in writing,
28
+ * software distributed under the License is distributed on an
29
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
30
+ * KIND, either express or implied.  See the License for the
31
+ * specific language governing permissions and limitations
32
+ * under the License.
33
+ * 
34
+ *************************************************************/
35
+
36
+
37
+
38
+// MARKER(update_precomp.py): autogen include statement, do not remove
39
+#include "precompiled_bridges.hxx"
40
+
41
+#include <string.h>
42
+
43
+#include <com/sun/star/uno/genfunc.hxx>
44
+#include <uno/data.h>
45
+#include <typelib/typedescription.hxx>
46
+
47
+#include "bridges/cpp_uno/shared/bridge.hxx"
48
+#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx"
49
+#include "bridges/cpp_uno/shared/types.hxx"
50
+#include "bridges/cpp_uno/shared/vtablefactory.hxx"
51
+
52
+#include "share.hxx"
53
+// #include <stdio.h>
54
+
55
+
56
+using namespace ::com::sun::star::uno;
57
+
58
+namespace
59
+{
60
+
61
+//==================================================================================================
62
+static typelib_TypeClass cpp2uno_call(
63
+	bridges::cpp_uno::shared::CppInterfaceProxy * pThis,
64
+	const typelib_TypeDescription * pMemberTypeDescr,
65
+	typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
66
+	sal_Int32 nParams, typelib_MethodParameter * pParams,
67
+        void ** gpreg, void ** fpreg, void ** ovrflw,
68
+	sal_Int64 * pRegisterReturn /* space for register return */ )
69
+{
70
+        int ng = 0; //number of gpr registers used 
71
+#ifndef __NO_FPRS__
72
+        int nf = 0; //number of fpr regsiters used
73
+#endif
74
+        void ** pCppStack; //temporary stack pointer
75
+       
76
+        // gpreg:  [ret *], this, [gpr params]
77
+        // fpreg:  [fpr params]
78
+        // ovrflw: [gpr or fpr params (properly aligned)]
79
+
80
+	// return
81
+	typelib_TypeDescription * pReturnTypeDescr = 0;
82
+	if (pReturnTypeRef)
83
+		TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
84
+	
85
+	void * pUnoReturn = 0;
86
+	void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
87
+	
88
+	if (pReturnTypeDescr)
89
+	{
90
+		if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
91
+		{
92
+			pUnoReturn = pRegisterReturn; // direct way for simple types
93
+		}
94
+		else // complex return via ptr (pCppReturn)
95
+		{
96
+			pCppReturn = *(void **)gpreg;
97
+                        gpreg++;
98
+                        ng++;
99
+			
100
+			pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
101
+						  ? alloca( pReturnTypeDescr->nSize )
102
+						  : pCppReturn); // direct way
103
+		}
104
+	}
105
+	// pop this
106
+        gpreg++; 
107
+        ng++;
108
+
109
+	// stack space
110
+	OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
111
+	// parameters
112
+	void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
113
+	void ** pCppArgs = pUnoArgs + nParams;
114
+	// indizes of values this have to be converted (interface conversion cpp<=>uno)
115
+	sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams));
116
+	// type descriptions for reconversions
117
+	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
118
+	
119
+	sal_Int32 nTempIndizes   = 0;
120
+	
121
+	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
122
+	{
123
+		const typelib_MethodParameter & rParam = pParams[nPos];
124
+		typelib_TypeDescription * pParamTypeDescr = 0;
125
+		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
126
+
127
+		if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) 
128
+                // value
129
+		{
130
+
131
+			switch (pParamTypeDescr->eTypeClass)
132
+			{
133
+
134
+			  case typelib_TypeClass_DOUBLE:
135
+#ifndef __NO_FPRS__
136
+			   if (nf < 8) {
137
+			      pCppArgs[nPos] = fpreg;
138
+			      pUnoArgs[nPos] = fpreg;
139
+			      nf++;
140
+			      fpreg += 2;
141
+#else
142
+               if (ng & 1) {
143
+                   ng++;
144
+                   gpreg++;
145
+               }
146
+               if (ng < 8) {
147
+                   pCppArgs[nPos] = gpreg;
148
+                   pUnoArgs[nPos] = gpreg;
149
+                   ng += 2;
150
+                   gpreg += 2;
151
+#endif
152
+			   } else {
153
+				if (((long)ovrflw) & 4) ovrflw++;
154
+				pCppArgs[nPos] = ovrflw;
155
+				pUnoArgs[nPos] = ovrflw;
156
+			        ovrflw += 2;
157
+			   }
158
+			   break;
159
+
160
+			   case typelib_TypeClass_FLOAT:
161
+			    // fpreg are all double values so need to
162
+			    // modify fpreg to be a single word float value
163
+#ifndef __NO_FPRS__
164
+			    if (nf < 8) {
165
+			       float tmp = (float) (*((double *)fpreg));
166
+			       (*((float *) fpreg)) = tmp;
167
+			       pCppArgs[nPos] = fpreg;
168
+			       pUnoArgs[nPos] = fpreg;
169
+			       nf++;
170
+			       fpreg += 2;
171
+#else
172
+                if (ng < 8) {
173
+                   pCppArgs[nPos] = gpreg;
174
+                   pUnoArgs[nPos] = gpreg;
175
+                   ng++;
176
+                   gpreg++;
177
+#endif
178
+			    } else {
179
+#if 0 /* abi is not being followed correctly */
180
+			      if (((long)ovrflw) & 4) ovrflw++;
181
+			      float tmp = (float) (*((double *)ovrflw));
182
+			      (*((float *) ovrflw)) = tmp;
183
+			      pCppArgs[nPos] = ovrflw;
184
+			      pUnoArgs[nPos] = ovrflw;
185
+			      ovrflw += 2;
186
+#else
187
+                              pCppArgs[nPos] = ovrflw;
188
+			      pUnoArgs[nPos] = ovrflw;
189
+			      ovrflw += 1;
190
+#endif
191
+                            }
192
+			    break;
193
+
194
+			case typelib_TypeClass_HYPER:
195
+			case typelib_TypeClass_UNSIGNED_HYPER:
196
+			 if (ng & 1) {
197
+			    ng++;
198
+			    gpreg++;
199
+			 }  
200
+			 if (ng < 8) {
201
+			    pCppArgs[nPos] = gpreg;
202
+			    pUnoArgs[nPos] = gpreg;
203
+			    ng += 2;
204
+			    gpreg += 2;
205
+			 } else {
206
+			    if (((long)ovrflw) & 4) ovrflw++;
207
+			    pCppArgs[nPos] = ovrflw;
208
+			    pUnoArgs[nPos] = ovrflw;
209
+			    ovrflw += 2;
210
+			  }
211
+			  break;
212
+
213
+			case typelib_TypeClass_BYTE:
214
+			case typelib_TypeClass_BOOLEAN:
215
+			 if (ng < 8) {
216
+			      pCppArgs[nPos] = (((char *)gpreg) + 3);
217
+			      pUnoArgs[nPos] = (((char *)gpreg) + 3);
218
+			      ng++;
219
+			      gpreg++;
220
+			 } else {
221
+			      pCppArgs[nPos] = (((char *)ovrflw) + 3);
222
+			      pUnoArgs[nPos] = (((char *)ovrflw) + 3);
223
+			      ovrflw++;
224
+			 }
225
+			 break;
226
+
227
+
228
+		       case typelib_TypeClass_CHAR:
229
+		       case typelib_TypeClass_SHORT:
230
+		       case typelib_TypeClass_UNSIGNED_SHORT:
231
+			if (ng < 8) {
232
+			      pCppArgs[nPos] = (((char *)gpreg)+ 2);
233
+			      pUnoArgs[nPos] = (((char *)gpreg)+ 2);
234
+			      ng++;
235
+			      gpreg++;
236
+			} else {
237
+			      pCppArgs[nPos] = (((char *)ovrflw) + 2);
238
+			      pUnoArgs[nPos] = (((char *)ovrflw) + 2);
239
+			      ovrflw++;
240
+			}
241
+			break;
242
+
243
+
244
+		      default:
245
+			if (ng < 8) {
246
+			      pCppArgs[nPos] = gpreg;
247
+			      pUnoArgs[nPos] = gpreg;
248
+			      ng++;
249
+			      gpreg++;
250
+			} else {
251
+			      pCppArgs[nPos] = ovrflw;
252
+			      pUnoArgs[nPos] = ovrflw;
253
+			      ovrflw++;
254
+			}
255
+                        break;
256
+
257
+		        }
258
+		        // no longer needed
259
+			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
260
+		}
261
+		else // ptr to complex value | ref
262
+		{
263
+
264
+		        if (ng < 8) { 
265
+		          pCppArgs[nPos] = *(void **)gpreg;
266
+		          pCppStack = gpreg;
267
+		          ng++;
268
+		          gpreg++;
269
+		        } else {
270
+		          pCppArgs[nPos] = *(void **)ovrflw;
271
+		          pCppStack = ovrflw;
272
+		         ovrflw++;
273
+		        }
274
+
275
+			if (! rParam.bIn) // is pure out
276
+			{
277
+				// uno out is unconstructed mem!
278
+				pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
279
+				pTempIndizes[nTempIndizes] = nPos;
280
+				// will be released at reconversion
281
+				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
282
+			}
283
+			// is in/inout
284
+			else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
285
+			{
286
+				uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
287
+										*(void **)pCppStack, pParamTypeDescr,
288
+										pThis->getBridge()->getCpp2Uno() );
289
+				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
290
+				// will be released at reconversion
291
+				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
292
+			}
293
+			else // direct way
294
+			{
295
+				pUnoArgs[nPos] = *(void **)pCppStack;
296
+				// no longer needed
297
+				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
298
+			}
299
+		}
300
+	}
301
+	
302
+	// ExceptionHolder
303
+	uno_Any aUnoExc; // Any will be constructed by callee
304
+	uno_Any * pUnoExc = &aUnoExc;
305
+
306
+	// invoke uno dispatch call
307
+	(*pThis->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
308
+	
309
+	// in case an exception occured...
310
+	if (pUnoExc)
311
+	{
312
+		// destruct temporary in/inout params
313
+		for ( ; nTempIndizes--; )
314
+		{
315
+			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
316
+			
317
+			if (pParams[nIndex].bIn) // is in/inout => was constructed
318
+				uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], 0 );
319
+			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
320
+		}
321
+		if (pReturnTypeDescr)
322
+			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
323
+		
324
+		CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc, pThis->getBridge()->getUno2Cpp() ); 
325
+                // has to destruct the any
326
+		// is here for dummy
327
+		return typelib_TypeClass_VOID;
328
+	}
329
+	else // else no exception occured...
330
+	{
331
+		// temporary params
332
+		for ( ; nTempIndizes--; )
333
+		{
334
+			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
335
+			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
336
+			
337
+			if (pParams[nIndex].bOut) // inout/out
338
+			{
339
+				// convert and assign
340
+				uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
341
+				uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
342
+										pThis->getBridge()->getUno2Cpp() );
343
+			}
344
+			// destroy temp uno param
345
+			uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
346
+			
347
+			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
348
+		}
349
+		// return
350
+		if (pCppReturn) // has complex return
351
+		{
352
+			if (pUnoReturn != pCppReturn) // needs reconversion
353
+			{
354
+				uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
355
+										pThis->getBridge()->getUno2Cpp() );
356
+				// destroy temp uno return
357
+				uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
358
+			}
359
+			// complex return ptr is set to return reg
360
+			*(void **)pRegisterReturn = pCppReturn;
361
+		}
362
+		if (pReturnTypeDescr)
363
+		{
364
+			typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
365
+			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
366
+			return eRet;
367
+		}
368
+		else
369
+			return typelib_TypeClass_VOID;
370
+	}
371
+}
372
+
373
+
374
+//==================================================================================================
375
+static typelib_TypeClass cpp_mediate(
376
+	sal_Int32 nFunctionIndex,
377
+        sal_Int32 nVtableOffset,
378
+        void ** gpreg, void ** fpreg, void ** ovrflw,
379
+	sal_Int64 * pRegisterReturn /* space for register return */ )
380
+{
381
+	OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" );
382
+	
383
+	// gpreg:  [ret *], this, [other gpr params]
384
+	// fpreg:  [fpr params]
385
+	// ovrflw: [gpr or fpr params (properly aligned)]
386
+
387
+        void * pThis;
388
+        if (nFunctionIndex & 0x80000000 )
389
+	{
390
+		nFunctionIndex &= 0x7fffffff;
391
+		pThis = gpreg[1];
392
+	}
393
+	else
394
+        {
395
+		pThis = gpreg[0];
396
+        }
397
+    
398
+        pThis = static_cast< char * >(pThis) - nVtableOffset;
399
+        bridges::cpp_uno::shared::CppInterfaceProxy * pCppI
400
+		  = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy(
401
+			pThis);
402
+
403
+	typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
404
+	
405
+	OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
406
+	if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
407
+	{
408
+		throw RuntimeException(
409
+            rtl::OUString::createFromAscii("illegal vtable index!"),
410
+            (XInterface *)pThis );
411
+	}
412
+	
413
+	// determine called method
414
+	sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex];
415
+	OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
416
+
417
+	TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
418
+    
419
+	typelib_TypeClass eRet;
420
+	switch (aMemberDescr.get()->eTypeClass)
421
+	{
422
+	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
423
+	{
424
+		if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
425
+		{
426
+			// is GET method
427
+			eRet = cpp2uno_call(
428
+				pCppI, aMemberDescr.get(),
429
+				((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
430
+				0, 0, // no params
431
+				gpreg, fpreg, ovrflw, pRegisterReturn );
432
+		}
433
+		else
434
+		{
435
+			// is SET method
436
+			typelib_MethodParameter aParam;
437
+			aParam.pTypeRef =
438
+				((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
439
+			aParam.bIn		= sal_True;
440
+			aParam.bOut		= sal_False;
441
+			
442
+			eRet = cpp2uno_call(
443
+				pCppI, aMemberDescr.get(),
444
+				0, // indicates void return
445
+				1, &aParam,
446
+				gpreg, fpreg, ovrflw, pRegisterReturn );
447
+		}
448
+		break;
449
+	}
450
+	case typelib_TypeClass_INTERFACE_METHOD:
451
+	{
452
+		// is METHOD
453
+		switch (nFunctionIndex)
454
+		{
455
+		case 1: // acquire()
456
+			pCppI->acquireProxy(); // non virtual call!
457
+			eRet = typelib_TypeClass_VOID;
458
+			break;
459
+		case 2: // release()
460
+			pCppI->releaseProxy(); // non virtual call!
461
+			eRet = typelib_TypeClass_VOID;
462
+			break;
463
+		case 0: // queryInterface() opt
464
+		{
465
+			typelib_TypeDescription * pTD = 0;
466
+			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() );
467
+			if (pTD)
468
+			{
469
+                XInterface * pInterface = 0;
470
+                (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)(
471
+                    pCppI->getBridge()->getCppEnv(),
472
+                    (void **)&pInterface, pCppI->getOid().pData, 
473
+                    (typelib_InterfaceTypeDescription *)pTD );
474
+			
475
+                if (pInterface)
476
+                {
477
+                    ::uno_any_construct(
478
+                        reinterpret_cast< uno_Any * >( gpreg[0] ),
479
+                        &pInterface, pTD, cpp_acquire );
480
+                    pInterface->release();
481
+                    TYPELIB_DANGER_RELEASE( pTD );
482
+                    *(void **)pRegisterReturn = gpreg[0];
483
+                    eRet = typelib_TypeClass_ANY;
484
+                    break;
485
+                }
486
+                TYPELIB_DANGER_RELEASE( pTD );
487
+			}
488
+		} // else perform queryInterface()
489
+		default:
490
+			eRet = cpp2uno_call(
491
+				pCppI, aMemberDescr.get(),
492
+				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
493
+				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
494
+				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
495
+				gpreg, fpreg, ovrflw, pRegisterReturn );
496
+		}
497
+		break;
498
+	}
499
+	default:
500
+	{
501
+		throw RuntimeException(
502
+            rtl::OUString::createFromAscii("no member description found!"),
503
+            (XInterface *)pThis );
504
+		// is here for dummy
505
+		eRet = typelib_TypeClass_VOID;
506
+	}
507
+	}
508
+
509
+	return eRet;
510
+}
511
+
512
+//==================================================================================================
513
+/**
514
+ * is called on incoming vtable calls
515
+ * (called by asm snippets)
516
+ */
517
+static void cpp_vtable_call( int nFunctionIndex, int nVtableOffset, void** gpregptr, void** fpregptr, void** ovrflw)
518
+{
519
+        sal_Int32     gpreg[8];
520
+        memcpy( gpreg, gpregptr, 32);
521
+
522
+#ifndef __NO_FPRS__
523
+        double        fpreg[8];
524
+        memcpy( fpreg, fpregptr, 64);
525
+#endif
526
+
527
+	volatile long nRegReturn[2];
528
+
529
+        // fprintf(stderr,"in cpp_vtable_call nFunctionIndex is %x\n",nFunctionIndex);
530
+        // fprintf(stderr,"in cpp_vtable_call nVtableOffset is %x\n",nVtableOffset);
531
+        // fflush(stderr);
532
+
533
+	typelib_TypeClass aType = 
534
+             cpp_mediate( nFunctionIndex, nVtableOffset, (void**)gpreg,
535
+#ifndef __NO_FPRS__
536
+                 (void**)fpreg, 
537
+#else
538
+                 NULL,
539
+#endif
540
+                 ovrflw, (sal_Int64*)nRegReturn );
541
+    
542
+	switch( aType )
543
+	{
544
+
545
+                // move return value into register space
546
+                // (will be loaded by machine code snippet)
547
+
548
+                case typelib_TypeClass_BOOLEAN:
549
+                case typelib_TypeClass_BYTE:
550
+                  __asm__( "lbz 3,%0\n\t" : :
551
+			   "m"(nRegReturn[0]) );
552
+                  break;
553
+ 
554
+                case typelib_TypeClass_CHAR:
555
+                case typelib_TypeClass_SHORT:
556
+                case typelib_TypeClass_UNSIGNED_SHORT:
557
+                  __asm__( "lhz 3,%0\n\t" : :
558
+			   "m"(nRegReturn[0]) );
559
+                  break;
560
+
561
+		case typelib_TypeClass_FLOAT:
562
+#ifndef __NO_FPRS__
563
+                  __asm__( "lfs 1,%0\n\t" : :
564
+                           "m" (*((float*)nRegReturn)) );
565
+ #else
566
+                  __asm__( "lwz 3,%0\n\t" : :
567
+                           "m"(nRegReturn[0]) );
568
+#endif
569
+		  break;
570
+
571
+		case typelib_TypeClass_DOUBLE:
572
+#ifndef __NO_FPRS__
573
+		  __asm__( "lfd 1,%0\n\t" : :
574
+                           "m" (*((double*)nRegReturn)) );
575
+#else
576
+          __asm__( "lwz 3,%0\n\t" : :
577
+                           "m"(nRegReturn[0]) );
578
+          __asm__( "lwz 4,%0\n\t" : :
579
+                           "m"(nRegReturn[1]) );
580
+#endif
581
+		  break;
582
+
583
+		case typelib_TypeClass_HYPER:
584
+		case typelib_TypeClass_UNSIGNED_HYPER:
585
+		  __asm__( "lwz 4,%0\n\t" : :
586
+                           "m"(nRegReturn[1]) );  // fall through
587
+
588
+		default:
589
+		  __asm__( "lwz 3,%0\n\t" : :
590
+                           "m"(nRegReturn[0]) );
591
+		  break;
592
+	}
593
+}
594
+
595
+
596
+int const codeSnippetSize = 108;
597
+
598
+unsigned char *  codeSnippet( unsigned char * code, sal_Int32 functionIndex, sal_Int32 vtableOffset, 
599
+                              bool simpleRetType)
600
+{
601
+
602
+  // fprintf(stderr,"in codeSnippet functionIndex is %x\n", functionIndex);
603
+  // fprintf(stderr,"in codeSnippet vtableOffset is %x\n", vtableOffset);
604
+  // fflush(stderr);
605
+
606
+    if (! simpleRetType )
607
+        functionIndex |= 0x80000000;
608
+
609
+    unsigned long * p = (unsigned long *) code;
610
+    
611
+    // OSL_ASSERT( sizeof (long) == 4 );
612
+    OSL_ASSERT((((unsigned long)code) & 0x3) == 0 );  //aligned to 4 otherwise a mistake
613
+
614
+    /* generate this code */
615
+    // # so first save gpr 3 to gpr 10 (aligned to 4)
616
+    //	stw	r3,-2048(r1)
617
+    //	stw	r4,-2044(r1)
618
+    //	stw	r5,-2040(r1)
619
+    //	stw	r6,-2036(r1)
620
+    //	stw	r7,-2032(r1)
621
+    //	stw	r8,-2028(r1)
622
+    //	stw	r9,-2024(r1)
623
+    //	stw	r10,-2020(r1)
624
+
625
+
626
+    // # next save fpr 1 to fpr 8 (aligned to 8)
627
+    // if dedicated floating point registers are used
628
+    //	stfd	f1,-2016(r1)
629
+    //	stfd	f2,-2008(r1)
630
+    //	stfd	f3,-2000(r1)
631
+    //	stfd	f4,-1992(r1)
632
+    //	stfd	f5,-1984(r1)
633
+    //	stfd	f6,-1976(r1)
634
+    //	stfd	f7,-1968(r1)
635
+    //	stfd	f8,-1960(r1)
636
+
637
+    // # now here is where cpp_vtable_call must go
638
+    //	lis	r3,-8531
639
+    //	ori	r3,r3,48879
640
+    //	mtctr	r3
641
+
642
+    // # now load up the functionIndex
643
+    //	lis	r3,-8531
644
+    //	ori	r3,r3,48879
645
+
646
+    // # now load up the vtableOffset 
647
+    //	lis	r4,-8531
648
+    //	ori	r4,r4,48879
649
+
650
+    // #now load up the pointer to the saved gpr registers
651
+    //	addi	r5,r1,-2048
652
+
653
+    // #now load up the pointer to the saved fpr registers
654
+    //	addi	r6,r1,-2016
655
+    // if no dedicated floating point registers are used than we have NULL
656
+    // pointer there
657
+    //  li      r6, 0
658
+    //
659
+
660
+    // #now load up the pointer to the overflow call stack
661
+    //	addi	r7,r1,8
662
+    //	bctr
663
+
664
+      * p++ = 0x9061f800;
665
+      * p++ = 0x9081f804;
666
+      * p++ = 0x90a1f808;
667
+      * p++ = 0x90c1f80c;
668
+      * p++ = 0x90e1f810;
669
+      * p++ = 0x9101f814;
670
+      * p++ = 0x9121f818;
671
+      * p++ = 0x9141f81c;
672
+#ifndef __NO_FPRS__
673
+      * p++ = 0xd821f820;
674
+      * p++ = 0xd841f828;
675
+      * p++ = 0xd861f830;
676
+      * p++ = 0xd881f838;
677
+      * p++ = 0xd8a1f840;
678
+      * p++ = 0xd8c1f848;
679
+      * p++ = 0xd8e1f850;
680
+      * p++ = 0xd901f858;
681
+#else
682
+      /* these nops could be replaced with a smaller codeSnippetSize - 8 * 4 */
683
+      * p++ = 0x60000000;
684
+      * p++ = 0x60000000;
685
+      * p++ = 0x60000000;
686
+      * p++ = 0x60000000;
687
+      * p++ = 0x60000000;
688
+      * p++ = 0x60000000;
689
+      * p++ = 0x60000000;
690
+      * p++ = 0x60000000;
691
+#endif
692
+      * p++ = 0x3c600000 | (((unsigned long)cpp_vtable_call) >> 16);
693
+      * p++ = 0x60630000 | (((unsigned long)cpp_vtable_call) & 0x0000FFFF);
694
+      * p++ = 0x7c6903a6;
695
+      * p++ = 0x3c600000 | (((unsigned long)functionIndex) >> 16);
696
+      * p++ = 0x60630000 | (((unsigned long)functionIndex) & 0x0000FFFF);
697
+      * p++ = 0x3c800000 | (((unsigned long)vtableOffset) >> 16);
698
+      * p++ = 0x60840000 | (((unsigned long)vtableOffset) & 0x0000FFFF);
699
+      * p++ = 0x38a1f800;
700
+#ifndef __NO_FPRS__
701
+      * p++ = 0x38c1f820;
702
+#else
703
+      * p++ = 0x38c00000;
704
+#endif
705
+      * p++ = 0x38e10008;
706
+      * p++ = 0x4e800420;
707
+      return (code + codeSnippetSize);
708
+
709
+}
710
+
711
+
712
+}
713
+
714
+void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const * bptr, unsigned char const * eptr)
715
+{
716
+    int const lineSize = 32;
717
+    for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) {
718
+        __asm__ volatile ("dcbst 0, %0" : : "r"(p) : "memory");
719
+    }
720
+    __asm__ volatile ("sync" : : : "memory");
721
+    for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) {
722
+        __asm__ volatile ("icbi 0, %0" : : "r"(p) : "memory");
723
+    }
724
+    __asm__ volatile ("isync" : : : "memory");
725
+}
726
+
727
+struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; };
728
+
729
+bridges::cpp_uno::shared::VtableFactory::Slot *
730
+bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block)
731
+{
732
+    return static_cast< Slot * >(block) + 2;
733
+}
734
+
735
+sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
736
+    sal_Int32 slotCount)
737
+{
738
+    return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize;
739
+}
740
+
741
+bridges::cpp_uno::shared::VtableFactory::Slot *
742
+bridges::cpp_uno::shared::VtableFactory::initializeBlock(
743
+    void * block, sal_Int32 slotCount)
744
+{
745
+    Slot * slots = mapBlockToVtable(block);
746
+    slots[-2].fn = 0;
747
+    slots[-1].fn = 0;
748
+    return slots + slotCount;
749
+}
750
+
751
+unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
752
+    Slot ** slots, unsigned char * code, sal_PtrDiff writetoexecdiff,
753
+    typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
754
+    sal_Int32 functionCount, sal_Int32 vtableOffset)
755
+{
756
+     (*slots) -= functionCount;
757
+     Slot * s = *slots;
758
+  // fprintf(stderr, "in addLocalFunctions functionOffset is %x\n",functionOffset);
759
+  // fprintf(stderr, "in addLocalFunctions vtableOffset is %x\n",vtableOffset);
760
+  // fflush(stderr);
761
+
762
+    for (sal_Int32 i = 0; i < type->nMembers; ++i) {
763
+        typelib_TypeDescription * member = 0;
764
+        TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
765
+        OSL_ASSERT(member != 0);
766
+        switch (member->eTypeClass) {
767
+        case typelib_TypeClass_INTERFACE_ATTRIBUTE:
768
+            // Getter:
769
+            (s++)->fn = code + writetoexecdiff;
770
+            code = codeSnippet(
771
+                code, functionOffset++, vtableOffset,
772
+                bridges::cpp_uno::shared::isSimpleType(
773
+                    reinterpret_cast<
774
+                    typelib_InterfaceAttributeTypeDescription * >(
775
+                        member)->pAttributeTypeRef));
776
+
777
+            // Setter:
778
+            if (!reinterpret_cast<
779
+                typelib_InterfaceAttributeTypeDescription * >(
780
+                    member)->bReadOnly)
781
+            {
782
+                (s++)->fn = code + writetoexecdiff;
783
+                code = codeSnippet(code, functionOffset++, vtableOffset, true);
784
+            }
785
+            break;
786
+
787
+        case typelib_TypeClass_INTERFACE_METHOD:
788
+            (s++)->fn = code + writetoexecdiff;
789
+            code = codeSnippet(
790
+                code, functionOffset++, vtableOffset,
791
+                bridges::cpp_uno::shared::isSimpleType(
792
+                    reinterpret_cast<
793
+                    typelib_InterfaceMethodTypeDescription * >(
794
+                        member)->pReturnTypeRef));
795
+            break;
796
+
797
+        default:
798
+            OSL_ASSERT(false);
799
+            break;
800
+        }
801
+        TYPELIB_DANGER_RELEASE(member);
802
+    }
803
+    return code;
804
+}
805
+
806
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
807
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc/except.cxx
808
@@ -0,0 +1,283 @@
809
+/**************************************************************
810
+ * 
811
+ * Licensed to the Apache Software Foundation (ASF) under one
812
+ * or more contributor license agreements.  See the NOTICE file
813
+ * distributed with this work for additional information
814
+ * regarding copyright ownership.  The ASF licenses this file
815
+ * to you under the Apache License, Version 2.0 (the
816
+ * "License"); you may not use this file except in compliance
817
+ * with the License.  You may obtain a copy of the License at
818
+ * 
819
+ *   http://www.apache.org/licenses/LICENSE-2.0
820
+ * 
821
+ * Unless required by applicable law or agreed to in writing,
822
+ * software distributed under the License is distributed on an
823
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
824
+ * KIND, either express or implied.  See the License for the
825
+ * specific language governing permissions and limitations
826
+ * under the License.
827
+ * 
828
+ *************************************************************/
829
+
830
+
831
+
832
+// MARKER(update_precomp.py): autogen include statement, do not remove
833
+#include "precompiled_bridges.hxx"
834
+
835
+#include <stdio.h>
836
+#include <string.h>
837
+#include <dlfcn.h>
838
+#include <cxxabi.h>
839
+#include <hash_map>
840
+
841
+#include <rtl/strbuf.hxx>
842
+#include <rtl/ustrbuf.hxx>
843
+#include <osl/diagnose.h>
844
+#include <osl/mutex.hxx>
845
+
846
+#include <com/sun/star/uno/genfunc.hxx>
847
+#include <typelib/typedescription.hxx>
848
+#include <uno/any2.h>
849
+
850
+#include "share.hxx"
851
+
852
+
853
+using namespace ::std;
854
+using namespace ::osl;
855
+using namespace ::rtl;
856
+using namespace ::com::sun::star::uno;
857
+using namespace ::__cxxabiv1;
858
+
859
+
860
+namespace CPPU_CURRENT_NAMESPACE
861
+{
862
+
863
+void dummy_can_throw_anything( char const * )
864
+{
865
+}
866
+
867
+//==================================================================================================
868
+static OUString toUNOname( char const * p ) SAL_THROW( () )
869
+{
870
+#if OSL_DEBUG_LEVEL > 1
871
+    char const * start = p;
872
+#endif
873
+
874
+    // example: N3com3sun4star4lang24IllegalArgumentExceptionE
875
+
876
+	OUStringBuffer buf( 64 );
877
+    OSL_ASSERT( 'N' == *p );
878
+    ++p; // skip N
879
+
880
+    while ('E' != *p)
881
+    {
882
+        // read chars count
883
+        long n = (*p++ - '0');
884
+        while ('0' <= *p && '9' >= *p)
885
+        {
886
+            n *= 10;
887
+            n += (*p++ - '0');
888
+        }
889
+        buf.appendAscii( p, n );
890
+        p += n;
891
+        if ('E' != *p)
892
+            buf.append( (sal_Unicode)'.' );
893
+    }
894
+
895
+#if OSL_DEBUG_LEVEL > 1
896
+    OUString ret( buf.makeStringAndClear() );
897
+    OString c_ret( OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ) );
898
+    fprintf( stderr, "> toUNOname(): %s => %s\n", start, c_ret.getStr() );
899
+    return ret;
900
+#else
901
+    return buf.makeStringAndClear();
902
+#endif
903
+}
904
+
905
+//==================================================================================================
906
+class RTTI
907
+{
908
+    typedef hash_map< OUString, type_info *, OUStringHash > t_rtti_map;
909
+
910
+    Mutex m_mutex;
911
+	t_rtti_map m_rttis;
912
+    t_rtti_map m_generatedRttis;
913
+
914
+    void * m_hApp;
915
+
916
+public:
917
+    RTTI() SAL_THROW( () );
918
+    ~RTTI() SAL_THROW( () );
919
+
920
+    type_info * getRTTI( typelib_CompoundTypeDescription * ) SAL_THROW( () );
921
+};
922
+//__________________________________________________________________________________________________
923
+RTTI::RTTI() SAL_THROW( () )
924
+    : m_hApp( dlopen( 0, RTLD_LAZY ) )
925
+{
926
+}
927
+//__________________________________________________________________________________________________
928
+RTTI::~RTTI() SAL_THROW( () )
929
+{
930
+    dlclose( m_hApp );
931
+}
932
+
933
+//__________________________________________________________________________________________________
934
+type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THROW( () )
935
+{
936
+    type_info * rtti;
937
+
938
+    OUString const & unoName = *(OUString const *)&pTypeDescr->aBase.pTypeName;
939
+
940
+    MutexGuard guard( m_mutex );
941
+    t_rtti_map::const_iterator iRttiFind( m_rttis.find( unoName ) );
942
+    if (iRttiFind == m_rttis.end())
943
+    {
944
+        // RTTI symbol
945
+        OStringBuffer buf( 64 );
946
+        buf.append( RTL_CONSTASCII_STRINGPARAM("_ZTIN") );
947
+        sal_Int32 index = 0;
948
+        do
949
+        {
950
+            OUString token( unoName.getToken( 0, '.', index ) );
951
+            buf.append( token.getLength() );
952
+            OString c_token( OUStringToOString( token, RTL_TEXTENCODING_ASCII_US ) );
953
+            buf.append( c_token );
954
+        }
955
+        while (index >= 0);
956
+        buf.append( 'E' );
957
+
958
+        OString symName( buf.makeStringAndClear() );
959
+        rtti = (type_info *)dlsym( m_hApp, symName.getStr() );
960
+
961
+        if (rtti)
962
+        {
963
+            pair< t_rtti_map::iterator, bool > insertion(
964
+                m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
965
+            OSL_ENSURE( insertion.second, "### inserting new rtti failed?!" );
966
+        }
967
+        else
968
+        {
969
+            // try to lookup the symbol in the generated rtti map
970
+            t_rtti_map::const_iterator iFind( m_generatedRttis.find( unoName ) );
971
+            if (iFind == m_generatedRttis.end())
972
+            {
973
+                // we must generate it !
974
+                // symbol and rtti-name is nearly identical,
975
+                // the symbol is prefixed with _ZTI
976
+                char const * rttiName = symName.getStr() +4;
977
+#if OSL_DEBUG_LEVEL > 1
978
+                fprintf( stderr,"generated rtti for %s\n", rttiName );
979
+#endif
980
+                if (pTypeDescr->pBaseTypeDescription)
981
+                {
982
+                    // ensure availability of base
983
+                    type_info * base_rtti = getRTTI(
984
+                        (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription );
985
+                    rtti = new __si_class_type_info(
986
+                        strdup( rttiName ), (__class_type_info *)base_rtti );
987
+                }
988
+                else
989
+                {
990
+                    // this class has no base class
991
+                    rtti = new __class_type_info( strdup( rttiName ) );
992
+                }
993
+
994
+                pair< t_rtti_map::iterator, bool > insertion(
995
+                    m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
996
+                OSL_ENSURE( insertion.second, "### inserting new generated rtti failed?!" );
997
+            }
998
+            else // taking already generated rtti
999
+            {
1000
+                rtti = iFind->second;
1001
+            }
1002
+        }
1003
+    }
1004
+    else
1005
+    {
1006
+        rtti = iRttiFind->second;
1007
+    }
1008
+
1009
+    return rtti;
1010
+}
1011
+
1012
+//--------------------------------------------------------------------------------------------------
1013
+static void deleteException( void * pExc )
1014
+{
1015
+    __cxa_exception const * header = ((__cxa_exception const *)pExc - 1);
1016
+    typelib_TypeDescription * pTD = 0;
1017
+    OUString unoName( toUNOname( header->exceptionType->name() ) );
1018
+    ::typelib_typedescription_getByName( &pTD, unoName.pData );
1019
+    OSL_ENSURE( pTD, "### unknown exception type! leaving out destruction => leaking!!!" );
1020
+    if (pTD)
1021
+    {
1022
+		::uno_destructData( pExc, pTD, cpp_release );
1023
+		::typelib_typedescription_release( pTD );
1024
+	}
1025
+}
1026
+
1027
+//==================================================================================================
1028
+void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
1029
+{
1030
+    void * pCppExc;
1031
+    type_info * rtti;
1032
+
1033
+    {
1034
+    // construct cpp exception object
1035
+	typelib_TypeDescription * pTypeDescr = 0;
1036
+	TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
1037
+    OSL_ASSERT( pTypeDescr );
1038
+    if (! pTypeDescr)
1039
+        terminate();
1040
+
1041
+	pCppExc = __cxa_allocate_exception( pTypeDescr->nSize );
1042
+	::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
1043
+
1044
+	// destruct uno exception
1045
+	::uno_any_destruct( pUnoExc, 0 );
1046
+    // avoiding locked counts
1047
+    static RTTI * s_rtti = 0;
1048
+    if (! s_rtti)
1049
+    {
1050
+        MutexGuard guard( Mutex::getGlobalMutex() );
1051
+        if (! s_rtti)
1052
+        {
1053
+#ifdef LEAK_STATIC_DATA
1054
+            s_rtti = new RTTI();
1055
+#else
1056
+            static RTTI rtti_data;
1057
+            s_rtti = &rtti_data;
1058
+#endif
1059
+        }
1060
+    }
1061
+	rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr );
1062
+    TYPELIB_DANGER_RELEASE( pTypeDescr );
1063
+    OSL_ENSURE( rtti, "### no rtti for throwing exception!" );
1064
+    if (! rtti)
1065
+        terminate();
1066
+    }
1067
+
1068
+	__cxa_throw( pCppExc, rtti, deleteException );
1069
+}
1070
+
1071
+//==================================================================================================
1072
+void fillUnoException( __cxa_exception * header, uno_Any * pExc, uno_Mapping * pCpp2Uno )
1073
+{
1074
+    OSL_ENSURE( header, "### no exception header!!!" );
1075
+    if (! header)
1076
+        terminate();
1077
+
1078
+	typelib_TypeDescription * pExcTypeDescr = 0;
1079
+    OUString unoName( toUNOname( header->exceptionType->name() ) );
1080
+	::typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData );
1081
+    OSL_ENSURE( pExcTypeDescr, "### can not get type description for exception!!!" );
1082
+    if (! pExcTypeDescr)
1083
+        terminate();
1084
+
1085
+    // construct uno exception any
1086
+    ::uno_any_constructAndConvert( pExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno );
1087
+    ::typelib_typedescription_release( pExcTypeDescr );
1088
+}
1089
+
1090
+}
1091
+
1092
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1093
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc/makefile.mk
1094
@@ -0,0 +1,76 @@
1095
+#**************************************************************
1096
+#  
1097
+#  Licensed to the Apache Software Foundation (ASF) under one
1098
+#  or more contributor license agreements.  See the NOTICE file
1099
+#  distributed with this work for additional information
1100
+#  regarding copyright ownership.  The ASF licenses this file
1101
+#  to you under the Apache License, Version 2.0 (the
1102
+#  "License"); you may not use this file except in compliance
1103
+#  with the License.  You may obtain a copy of the License at
1104
+#  
1105
+#    http://www.apache.org/licenses/LICENSE-2.0
1106
+#  
1107
+#  Unless required by applicable law or agreed to in writing,
1108
+#  software distributed under the License is distributed on an
1109
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1110
+#  KIND, either express or implied.  See the License for the
1111
+#  specific language governing permissions and limitations
1112
+#  under the License.
1113
+#  
1114
+#**************************************************************
1115
+
1116
+
1117
+
1118
+PRJ=..$/..$/..
1119
+
1120
+PRJNAME=bridges
1121
+TARGET=gcc3_uno
1122
+LIBTARGET=no
1123
+ENABLE_EXCEPTIONS=TRUE
1124
+
1125
+# --- Settings -----------------------------------------------------
1126
+
1127
+.INCLUDE :  settings.mk
1128
+
1129
+# --- Files --------------------------------------------------------
1130
+.IF "$(COM)$(OS)$(CPU)$(COMNAME)$(CPUNAME)" == "GCCFREEBSDPgcc3POWERPC"
1131
+
1132
+.IF "$(cppu_no_leak)" == ""
1133
+CFLAGS += -DLEAK_STATIC_DATA
1134
+.ENDIF
1135
+
1136
+# In case someone enabled the non-standard -fomit-frame-pointer which does not
1137
+# work with the .cxx sources in this directory:
1138
+CFLAGSCXX += -fno-omit-frame-pointer
1139
+
1140
+NOOPTFILES= \
1141
+	$(SLO)$/uno2cpp.obj
1142
+
1143
+
1144
+CFLAGSNOOPT=-O0
1145
+
1146
+SLOFILES= \
1147
+	$(SLO)$/except.obj		\
1148
+	$(SLO)$/cpp2uno.obj		\
1149
+	$(SLO)$/uno2cpp.obj
1150
+
1151
+SHL1TARGET= $(TARGET)
1152
+
1153
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
1154
+SHL1IMPLIB=i$(TARGET)
1155
+SHL1VERSIONMAP=..$/..$/bridge_exports.map
1156
+SHL1RPATH=URELIB
1157
+
1158
+SHL1OBJS= $(SLOFILES)
1159
+SHL1LIBS = $(SLB)$/cpp_uno_shared.lib
1160
+
1161
+SHL1STDLIBS= \
1162
+	$(CPPULIB)			\
1163
+	$(SALLIB)
1164
+
1165
+.ENDIF
1166
+
1167
+# --- Targets ------------------------------------------------------
1168
+
1169
+.INCLUDE :  target.mk
1170
+
1171
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1172
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc/share.hxx
1173
@@ -0,0 +1,87 @@
1174
+/**************************************************************
1175
+ * 
1176
+ * Licensed to the Apache Software Foundation (ASF) under one
1177
+ * or more contributor license agreements.  See the NOTICE file
1178
+ * distributed with this work for additional information
1179
+ * regarding copyright ownership.  The ASF licenses this file
1180
+ * to you under the Apache License, Version 2.0 (the
1181
+ * "License"); you may not use this file except in compliance
1182
+ * with the License.  You may obtain a copy of the License at
1183
+ * 
1184
+ *   http://www.apache.org/licenses/LICENSE-2.0
1185
+ * 
1186
+ * Unless required by applicable law or agreed to in writing,
1187
+ * software distributed under the License is distributed on an
1188
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1189
+ * KIND, either express or implied.  See the License for the
1190
+ * specific language governing permissions and limitations
1191
+ * under the License.
1192
+ * 
1193
+ *************************************************************/
1194
+
1195
+
1196
+
1197
+#include "uno/mapping.h"
1198
+
1199
+#include <typeinfo>
1200
+#include <exception>
1201
+#include <cstddef>
1202
+
1203
+namespace CPPU_CURRENT_NAMESPACE
1204
+{
1205
+
1206
+  void dummy_can_throw_anything( char const * );
1207
+
1208
+
1209
+// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
1210
+
1211
+struct _Unwind_Exception
1212
+{
1213
+    unsigned exception_class __attribute__((__mode__(__DI__)));
1214
+    void * exception_cleanup;
1215
+    unsigned private_1 __attribute__((__mode__(__word__)));
1216
+    unsigned private_2 __attribute__((__mode__(__word__)));
1217
+} __attribute__((__aligned__));
1218
+
1219
+struct __cxa_exception
1220
+{ 
1221
+    ::std::type_info *exceptionType;
1222
+    void (*exceptionDestructor)(void *); 
1223
+    
1224
+    ::std::unexpected_handler unexpectedHandler;
1225
+    ::std::terminate_handler terminateHandler;
1226
+    
1227
+    __cxa_exception *nextException;
1228
+    
1229
+    int handlerCount;
1230
+    
1231
+    int handlerSwitchValue;
1232
+    const unsigned char *actionRecord;
1233
+    const unsigned char *languageSpecificData;
1234
+    void *catchTemp;
1235
+    void *adjustedPtr;
1236
+    
1237
+    _Unwind_Exception unwindHeader;
1238
+};    
1239
+
1240
+extern "C" void *__cxa_allocate_exception(
1241
+    std::size_t thrown_size ) throw();
1242
+extern "C" void __cxa_throw (
1243
+    void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
1244
+
1245
+struct __cxa_eh_globals
1246
+{
1247
+    __cxa_exception *caughtExceptions;
1248
+    unsigned int uncaughtExceptions;
1249
+};
1250
+extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
1251
+
1252
+// -----
1253
+
1254
+//==================================================================================================
1255
+void raiseException(
1256
+    uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
1257
+//==================================================================================================
1258
+void fillUnoException(
1259
+    __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
1260
+}
1261
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1262
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc/uno2cpp.cxx
1263
@@ -0,0 +1,668 @@
1264
+/**************************************************************
1265
+ * 
1266
+ * Licensed to the Apache Software Foundation (ASF) under one
1267
+ * or more contributor license agreements.  See the NOTICE file
1268
+ * distributed with this work for additional information
1269
+ * regarding copyright ownership.  The ASF licenses this file
1270
+ * to you under the Apache License, Version 2.0 (the
1271
+ * "License"); you may not use this file except in compliance
1272
+ * with the License.  You may obtain a copy of the License at
1273
+ * 
1274
+ *   http://www.apache.org/licenses/LICENSE-2.0
1275
+ * 
1276
+ * Unless required by applicable law or agreed to in writing,
1277
+ * software distributed under the License is distributed on an
1278
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1279
+ * KIND, either express or implied.  See the License for the
1280
+ * specific language governing permissions and limitations
1281
+ * under the License.
1282
+ * 
1283
+ *************************************************************/
1284
+
1285
+
1286
+
1287
+// MARKER(update_precomp.py): autogen include statement, do not remove
1288
+#include "precompiled_bridges.hxx"
1289
+
1290
+#include <stdlib.h>
1291
+
1292
+#include <com/sun/star/uno/genfunc.hxx>
1293
+#include <uno/data.h>
1294
+
1295
+#include "bridges/cpp_uno/shared/bridge.hxx"
1296
+#include "bridges/cpp_uno/shared/types.hxx"
1297
+#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
1298
+#include "bridges/cpp_uno/shared/vtables.hxx"
1299
+
1300
+#include "share.hxx"
1301
+
1302
+
1303
+using namespace ::rtl;
1304
+using namespace ::com::sun::star::uno;
1305
+
1306
+namespace
1307
+{
1308
+
1309
+
1310
+//==================================================================================================
1311
+static void callVirtualMethod(
1312
+    void * pAdjustedThisPtr,
1313
+    sal_Int32 nVtableIndex,
1314
+    void * pRegisterReturn,
1315
+    typelib_TypeClass eReturnType,
1316
+    char * pPT,
1317
+    sal_Int32 * pStackLongs,
1318
+    sal_Int32 nStackLongs)
1319
+{
1320
+
1321
+  // parameter list is mixed list of * and values
1322
+  // reference parameters are pointers
1323
+
1324
+  // the basic idea here is to use gpr[8] as a storage area for
1325
+  // the future values of registers r3 to r10 needed for the call, 
1326
+  // and similarly fpr[8] as a storage area for the future values
1327
+  // of floating point registers f1 to f8
1328
+
1329
+     unsigned long * mfunc;        // actual function to be invoked
1330
+     void (*ptr)();
1331
+     int gpr[8];                   // storage for gpregisters, map to r3-r10
1332
+     int off;                      // offset used to find function
1333
+#ifndef __NO_FPRS__
1334
+     double fpr[8];                // storage for fpregisters, map to f1-f8
1335
+     int f;                        // number of fprs mapped so far
1336
+     double dret;                  // temporary function return values
1337
+#endif
1338
+     int n;                        // number of gprs mapped so far
1339
+     long *p;                      // pointer to parameter overflow area
1340
+     int c;                        // character of parameter type being decoded
1341
+     int iret, iret2;
1342
+
1343
+     // Because of the Power PC calling conventions we could be passing
1344
+     // parameters in both register types and on the stack. To create the
1345
+     // stack parameter area we need we now simply allocate local
1346
+     // variable storage param[] that is at least the size of the parameter stack
1347
+     // (more than enough space) which we can overwrite the parameters into.
1348
+
1349
+     // Note: This keeps us from having to decode the signature twice and
1350
+     // prevents problems with later local variables.
1351
+
1352
+     // Note: could require up to  2*nStackLongs words of parameter stack area 
1353
+     // if the call has many float parameters (i.e. floats take up only 1 
1354
+     // word on the stack but double takes 2 words in parameter area in the
1355
+     // stack frame .
1356
+
1357
+     // Update! floats on the outgoing parameter stack only take up 1 word
1358
+     // (stfs is used) which is not correct according to the ABI but we
1359
+     // will match what the compiler does until this is figured out 
1360
+
1361
+     // this grows the current stack to the appropriate size
1362
+     // and sets the outgoing stack pointer p to the right place
1363
+     __asm__ __volatile__ (
1364
+          "rlwinm %0,%0,3,3,28\n\t"
1365
+          "addi %0,%0,22\n\t"
1366
+          "rlwinm %0,%0,0,4,28\n\t"
1367
+          "lwz 0,0(1)\n\t"
1368
+          "subf 1,%0,1\n\t"
1369
+          "stw 0,0(1)\n\t"
1370
+          : : "r" (nStackLongs) : "0" );
1371
+
1372
+     __asm__ __volatile__ ( "addi %0,1,8" : "=r" (p) : );
1373
+
1374
+     // never called
1375
+     // if (! pAdjustedThisPtr ) dummy_can_throw_anything("xxx"); // address something
1376
+
1377
+
1378
+     // now begin to load the C++ function arguments into storage
1379
+     n = 0;
1380
+#ifndef __NO_FPRS__
1381
+     f = 0;
1382
+#endif
1383
+
1384
+     // now we need to parse the entire signature string */
1385
+     // until we get the END indicator */
1386
+
1387
+     // treat complex return pointer like any other parameter //
1388
+
1389
+#if 0
1390
+     /* Let's figure out what is really going on here*/
1391
+     fprintf(stderr,"callVirtualMethod paramters string is %s\n",pPT);
1392
+     int k = nStackLongs;
1393
+     long * q = (long *)pStackLongs;
1394
+     while (k > 0) {
1395
+       fprintf(stderr,"uno stack is: %x\n",*q);
1396
+       k--;
1397
+       q++;
1398
+     }
1399
+#endif
1400
+
1401
+     /* parse the argument list up to the ending ) */
1402
+     while (*pPT != 'X') {
1403
+       c = *pPT;
1404
+       switch (c) {
1405
+       case 'D':                   /* type is double */
1406
+#ifndef __NO_FPRS__
1407
+            if (f < 8) {
1408
+               fpr[f++] = *((double *)pStackLongs);   /* store in register */
1409
+#else
1410
+            if (n & 1)
1411
+               n++;
1412
+            if (n < 8) {
1413
+               gpr[n++] = *pStackLongs;
1414
+               gpr[n++] = *(pStackLongs+1);
1415
+#endif
1416
+	    } else {
1417
+	       if (((long) p) & 4)          
1418
+	          p++;
1419
+               *p++ = *pStackLongs;       /* or on the parameter stack */
1420
+               *p++ = *(pStackLongs + 1);
1421
+	    }
1422
+            pStackLongs += 2;
1423
+            break;
1424
+
1425
+       case 'F':                   /* type is float */
1426
+	 /* this assumes that floats are stored as 1 32 bit word on param
1427
+	    stack and that if passed in parameter stack to C, should be
1428
+	    as double word.
1429
+
1430
+            Whoops: the abi is not actually followed by gcc, need to 
1431
+            store floats as a *single* word on outgoing parameter stack
1432
+            to match what gcc actually does
1433
+	 */
1434
+#ifndef __NO_FPRS__
1435
+            if (f < 8) {
1436
+               fpr[f++] = *((float *)pStackLongs);
1437
+#else
1438
+            if (n < 8) {
1439
+               gpr[n++] = *pStackLongs;
1440
+#endif
1441
+	    } else {
1442
+#if 0 /* if abi were followed */
1443
+	       if (((long) p) & 4)          
1444
+	          p++;
1445
+	       *((double *)p) = *((float *)pStackLongs);
1446
+               p += 2;
1447
+#else
1448
+	       *((float *)p) = *((float *)pStackLongs);
1449
+               p += 1;
1450
+#endif
1451
+	    }
1452
+            pStackLongs += 1;
1453
+            break;
1454
+
1455
+       case 'H':                /* type is long long */
1456
+            if (n & 1) n++; 	/* note even elements gpr[] will map to
1457
+                                   odd registers*/
1458
+            if (n <= 6) {
1459
+               gpr[n++] = *pStackLongs;
1460
+               gpr[n++] = *(pStackLongs+1);
1461
+	    } else {
1462
+	       if (((long) p) & 4)          
1463
+	          p++;
1464
+               *p++ = *pStackLongs;
1465
+               *p++ = *(pStackLongs+1);
1466
+	    }
1467
+            pStackLongs += 2;
1468
+            break;
1469
+
1470
+       case 'S':
1471
+            if (n < 8) {
1472
+               gpr[n++] = *((unsigned short*)pStackLongs);
1473
+	    } else {
1474
+               *p++ = *((unsigned short *)pStackLongs);
1475
+	    }
1476
+            pStackLongs += 1;
1477
+            break;
1478
+
1479
+       case 'B':
1480
+            if (n < 8) {
1481
+               gpr[n++] = *((char *)pStackLongs);
1482
+	    } else {
1483
+               *p++ = *((char *)pStackLongs);
1484
+	    }
1485
+            pStackLongs += 1;
1486
+            break;
1487
+
1488
+       default:
1489
+            if (n < 8) {
1490
+               gpr[n++] = *pStackLongs;
1491
+	    } else {
1492
+               *p++ = *pStackLongs;
1493
+	    }
1494
+            pStackLongs += 1;
1495
+            break;
1496
+       }
1497
+       pPT++;
1498
+     }
1499
+
1500
+     /* figure out the address of the function we need to invoke */
1501
+     off = nVtableIndex; 
1502
+     off = off * 4;                         // 4 bytes per slot
1503
+     mfunc = *((unsigned long **)pAdjustedThisPtr);    // get the address of the vtable
1504
+     mfunc = (unsigned long *)((char *)mfunc + off); // get the address from the vtable entry at offset 
1505
+     mfunc = *((unsigned long **)mfunc);                 // the function is stored at the address
1506
+     ptr = (void (*)())mfunc;   
1507
+
1508
+    /* Set up the machine registers and invoke the function */
1509
+
1510
+    __asm__ __volatile__ (
1511
+		"lwz	3,	0(%0)\n\t"
1512
+		"lwz	4,	4(%0)\n\t"
1513
+		"lwz	5,	8(%0)\n\t"
1514
+		"lwz	6,	12(%0)\n\t"
1515
+		"lwz	7,	16(%0)\n\t"
1516
+		"lwz	8,	20(%0)\n\t"
1517
+		"lwz	9,	24(%0)\n\t"
1518
+		"lwz	10,	28(%0)\n\t"
1519
+#ifndef __NO_FPRS__
1520
+		"lfd	1,	0(%1)\n\t"
1521
+		"lfd	2,	8(%1)\n\t"
1522
+		"lfd	3,	16(%1)\n\t"
1523
+		"lfd	4,	24(%1)\n\t"
1524
+		"lfd	5,	32(%1)\n\t"
1525
+		"lfd	6,	40(%1)\n\t"
1526
+		"lfd	7,	48(%1)\n\t"
1527
+		"lfd	8,	56(%1)\n\t"
1528
+	        : : "r" (gpr), "r" (fpr)
1529
+#else
1530
+	        : : "r" (gpr)
1531
+#endif
1532
+		: "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"
1533
+    );
1534
+
1535
+    (*ptr)();
1536
+
1537
+    __asm__ __volatile__ (
1538
+       "mr     %0,     3\n\t"
1539
+       "mr     %1,     4\n\t"
1540
+#ifndef __NO_FPRS__
1541
+       "fmr    %2,     1\n\t"
1542
+       : "=r" (iret), "=r" (iret2), "=f" (dret)
1543
+#else
1544
+       : "=r" (iret), "=r" (iret2)
1545
+#endif
1546
+       : );
1547
+
1548
+    switch( eReturnType )
1549
+	{
1550
+		case typelib_TypeClass_HYPER:
1551
+		case typelib_TypeClass_UNSIGNED_HYPER:
1552
+		        ((long*)pRegisterReturn)[0] = iret;
1553
+			((long*)pRegisterReturn)[1] = iret2;
1554
+		case typelib_TypeClass_LONG:
1555
+		case typelib_TypeClass_UNSIGNED_LONG:
1556
+		case typelib_TypeClass_ENUM:
1557
+			((long*)pRegisterReturn)[0] = iret;
1558
+			break;
1559
+		case typelib_TypeClass_CHAR:
1560
+		case typelib_TypeClass_SHORT:
1561
+		case typelib_TypeClass_UNSIGNED_SHORT:
1562
+		        *(unsigned short*)pRegisterReturn = (unsigned short)iret;
1563
+			break;
1564
+		case typelib_TypeClass_BOOLEAN:
1565
+		case typelib_TypeClass_BYTE:
1566
+		        *(unsigned char*)pRegisterReturn = (unsigned char)iret;
1567
+			break;
1568
+		case typelib_TypeClass_FLOAT:
1569
+#ifndef __NO_FPRS__
1570
+		        *(float*)pRegisterReturn = (float)dret;
1571
+#else
1572
+		        ((unsigned int*)pRegisterReturn)[0] = iret;
1573
+#endif
1574
+			break;
1575
+		case typelib_TypeClass_DOUBLE:
1576
+#ifndef __NO_FPRS__
1577
+			*(double*)pRegisterReturn = dret;
1578
+#else
1579
+			((unsigned int*)pRegisterReturn)[0] = iret;
1580
+			((unsigned int*)pRegisterReturn)[1] = iret2;
1581
+#endif
1582
+			break;
1583
+		default:
1584
+			break;
1585
+	}
1586
+}
1587
+
1588
+
1589
+//================================================================================================== 
1590
+static void cpp_call(
1591
+	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
1592
+	bridges::cpp_uno::shared::VtableSlot  aVtableSlot,
1593
+	typelib_TypeDescriptionReference * pReturnTypeRef,
1594
+	sal_Int32 nParams, typelib_MethodParameter * pParams,
1595
+	void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
1596
+{
1597
+  	// max space for: [complex ret ptr], values|ptr ...
1598
+  	char * pCppStack		=
1599
+  		(char *)alloca( sizeof(sal_Int32) + ((nParams+2) * sizeof(sal_Int64)) );
1600
+  	char * pCppStackStart	= pCppStack;
1601
+	
1602
+        // need to know parameter types for callVirtualMethod so generate a signature string
1603
+        char * pParamType = (char *) alloca(nParams+2);
1604
+        char * pPT = pParamType;
1605
+
1606
+	// return
1607
+	typelib_TypeDescription * pReturnTypeDescr = 0;
1608
+	TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
1609
+	// OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
1610
+	
1611
+	void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
1612
+	
1613
+	if (pReturnTypeDescr)
1614
+	{
1615
+		if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
1616
+		{
1617
+			pCppReturn = pUnoReturn; // direct way for simple types
1618
+		}
1619
+		else
1620
+		{
1621
+			// complex return via ptr
1622
+			pCppReturn = *(void **)pCppStack = 
1623
+                              (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
1624
+			       ? alloca( pReturnTypeDescr->nSize ): pUnoReturn); // direct way
1625
+                        *pPT++ = 'I'; //signify that a complex return type on stack
1626
+			pCppStack += sizeof(void *);
1627
+		}
1628
+	}
1629
+	// push this
1630
+        void* pAdjustedThisPtr = reinterpret_cast< void **>(pThis->getCppI()) + aVtableSlot.offset;
1631
+	*(void**)pCppStack = pAdjustedThisPtr;
1632
+	pCppStack += sizeof( void* );
1633
+        *pPT++ = 'I';
1634
+
1635
+	// stack space
1636
+	// OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
1637
+	// args
1638
+	void ** pCppArgs  = (void **)alloca( 3 * sizeof(void *) * nParams );
1639
+	// indizes of values this have to be converted (interface conversion cpp<=>uno)
1640
+	sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
1641
+	// type descriptions for reconversions
1642
+	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
1643
+	
1644
+	sal_Int32 nTempIndizes   = 0;
1645
+	
1646
+	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
1647
+	{
1648
+		const typelib_MethodParameter & rParam = pParams[nPos];
1649
+		typelib_TypeDescription * pParamTypeDescr = 0;
1650
+		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
1651
+		
1652
+		if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
1653
+		{
1654
+			uno_copyAndConvertData( pCppArgs[nPos] = pCppStack, pUnoArgs[nPos], pParamTypeDescr,
1655
+									pThis->getBridge()->getUno2Cpp() );
1656
+			
1657
+			switch (pParamTypeDescr->eTypeClass)
1658
+			{
1659
+
1660
+                          // we need to know type of each param so that we know whether to use
1661
+                          // gpr or fpr to pass in parameters:
1662
+                          // Key: I - int, long, pointer, etc means pass in gpr
1663
+                          //      B - byte value passed in gpr
1664
+                          //      S - short value passed in gpr
1665
+                          //      F - float value pass in fpr
1666
+                          //      D - double value pass in fpr
1667
+                          //      H - long long int pass in proper pairs of gpr (3,4) (5,6), etc
1668
+                          //      X - indicates end of parameter description string
1669
+
1670
+		          case typelib_TypeClass_LONG:
1671
+		          case typelib_TypeClass_UNSIGNED_LONG:
1672
+		          case typelib_TypeClass_ENUM:
1673
+			    *pPT++ = 'I';
1674
+			    break;
1675
+ 		          case typelib_TypeClass_SHORT:
1676
+		          case typelib_TypeClass_CHAR:
1677
+		          case typelib_TypeClass_UNSIGNED_SHORT:
1678
+                            *pPT++ = 'S';
1679
+                            break;
1680
+		          case typelib_TypeClass_BOOLEAN:
1681
+		          case typelib_TypeClass_BYTE:
1682
+                            *pPT++ = 'B';
1683
+                            break;
1684
+		          case typelib_TypeClass_FLOAT:
1685
+                            *pPT++ = 'F';
1686
+			    break;
1687
+		        case typelib_TypeClass_DOUBLE:
1688
+			    *pPT++ = 'D';
1689
+			    pCppStack += sizeof(sal_Int32); // extra long
1690
+			    break;
1691
+			case typelib_TypeClass_HYPER:
1692
+			case typelib_TypeClass_UNSIGNED_HYPER:
1693
+			    *pPT++ = 'H';
1694
+			    pCppStack += sizeof(sal_Int32); // extra long
1695
+			default:
1696
+			    break;
1697
+			}
1698
+
1699
+			// no longer needed
1700
+			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
1701
+		}
1702
+		else // ptr to complex value | ref
1703
+		{
1704
+			if (! rParam.bIn) // is pure out
1705
+			{
1706
+				// cpp out is constructed mem, uno out is not!
1707
+				uno_constructData(
1708
+					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
1709
+					pParamTypeDescr );
1710
+				pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
1711
+				// will be released at reconversion
1712
+				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
1713
+			}
1714
+			// is in/inout
1715
+			else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
1716
+			{
1717
+				uno_copyAndConvertData(
1718
+					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
1719
+					pUnoArgs[nPos], pParamTypeDescr, 
1720
+                                        pThis->getBridge()->getUno2Cpp() );
1721
+				
1722
+				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
1723
+				// will be released at reconversion
1724
+				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
1725
+			}
1726
+			else // direct way
1727
+			{
1728
+				*(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
1729
+				// no longer needed
1730
+				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
1731
+			}
1732
+                        // KBH: FIXME: is this the right way to pass these
1733
+                        *pPT++='I';
1734
+		}
1735
+		pCppStack += sizeof(sal_Int32); // standard parameter length
1736
+	}
1737
+  
1738
+        // terminate the signature string
1739
+        *pPT++='X';
1740
+        *pPT=0;
1741
+
1742
+	try
1743
+	{
1744
+		OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic)" );
1745
+		callVirtualMethod(
1746
+			pAdjustedThisPtr, aVtableSlot.index,
1747
+			pCppReturn, pReturnTypeDescr->eTypeClass, pParamType,
1748
+			(sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
1749
+		// NO exception occured...
1750
+		*ppUnoExc = 0;
1751
+		
1752
+		// reconvert temporary params
1753
+		for ( ; nTempIndizes--; )
1754
+		{
1755
+			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
1756
+			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
1757
+			
1758
+			if (pParams[nIndex].bIn)
1759
+			{
1760
+				if (pParams[nIndex].bOut) // inout
1761
+				{
1762
+					uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
1763
+					uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
1764
+											pThis->getBridge()->getCpp2Uno() );
1765
+				}
1766
+			}
1767
+			else // pure out
1768
+			{
1769
+				uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
1770
+										pThis->getBridge()->getCpp2Uno() );
1771
+			}
1772
+			// destroy temp cpp param => cpp: every param was constructed
1773
+			uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
1774
+			
1775
+			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
1776
+		}
1777
+		// return value
1778
+		if (pCppReturn && pUnoReturn != pCppReturn)
1779
+		{
1780
+			uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
1781
+									pThis->getBridge()->getCpp2Uno() );
1782
+			uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
1783
+		}
1784
+	}
1785
+ 	catch (...)
1786
+ 	{
1787
+  		// fill uno exception
1788
+		fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, 
1789
+                                  *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
1790
+        
1791
+		// temporary params
1792
+		for ( ; nTempIndizes--; )
1793
+		{
1794
+			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
1795
+			// destroy temp cpp param => cpp: every param was constructed
1796
+			uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
1797
+			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
1798
+		}
1799
+		// return type
1800
+		if (pReturnTypeDescr)
1801
+			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
1802
+	}
1803
+}
1804
+
1805
+}
1806
+
1807
+namespace bridges { namespace cpp_uno { namespace shared {
1808
+
1809
+void unoInterfaceProxyDispatch(
1810
+	uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
1811
+	void * pReturn, void * pArgs[], uno_Any ** ppException )
1812
+{
1813
+	// is my surrogate
1814
+        bridges::cpp_uno::shared::UnoInterfaceProxy * pThis 
1815
+            = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy *> (pUnoI);
1816
+	
1817
+	switch (pMemberDescr->eTypeClass)
1818
+	{
1819
+	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
1820
+	{
1821
+
1822
+        VtableSlot aVtableSlot(
1823
+            getVtableSlot(
1824
+                reinterpret_cast<
1825
+                    typelib_InterfaceAttributeTypeDescription const * >(
1826
+                        pMemberDescr)));
1827
+
1828
+		if (pReturn)
1829
+		{
1830
+			// dependent dispatch
1831
+			cpp_call(
1832
+				pThis, aVtableSlot,
1833
+				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
1834
+				0, 0, // no params
1835
+				pReturn, pArgs, ppException );
1836
+		}
1837
+		else
1838
+		{
1839
+			// is SET
1840
+			typelib_MethodParameter aParam;
1841
+			aParam.pTypeRef =
1842
+				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
1843
+			aParam.bIn		= sal_True;
1844
+			aParam.bOut		= sal_False;
1845
+
1846
+			typelib_TypeDescriptionReference * pReturnTypeRef = 0;
1847
+			OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
1848
+			typelib_typedescriptionreference_new(
1849
+				&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
1850
+			
1851
+			// dependent dispatch
1852
+                        aVtableSlot.index += 1; //get then set method
1853
+			cpp_call(
1854
+				pThis, aVtableSlot,
1855
+				pReturnTypeRef,
1856
+				1, &aParam,
1857
+				pReturn, pArgs, ppException );
1858
+			
1859
+			typelib_typedescriptionreference_release( pReturnTypeRef );
1860
+		}
1861
+		
1862
+		break;
1863
+	}
1864
+	case typelib_TypeClass_INTERFACE_METHOD:
1865
+	{
1866
+
1867
+        VtableSlot aVtableSlot(
1868
+            getVtableSlot(
1869
+                reinterpret_cast<
1870
+                    typelib_InterfaceMethodTypeDescription const * >(
1871
+                        pMemberDescr)));
1872
+		switch (aVtableSlot.index)
1873
+		{
1874
+			// standard calls
1875
+		case 1: // acquire uno interface
1876
+			(*pUnoI->acquire)( pUnoI );
1877
+			*ppException = 0;
1878
+			break;
1879
+		case 2: // release uno interface
1880
+			(*pUnoI->release)( pUnoI );
1881
+			*ppException = 0;
1882
+			break;
1883
+		case 0: // queryInterface() opt
1884
+		{
1885
+			typelib_TypeDescription * pTD = 0;
1886
+			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
1887
+			if (pTD)
1888
+			{
1889
+                uno_Interface * pInterface = 0;
1890
+                (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
1891
+                    pThis->pBridge->getUnoEnv(),
1892
+                    (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
1893
+			
1894
+                if (pInterface)
1895
+                {
1896
+                    ::uno_any_construct(
1897
+                        reinterpret_cast< uno_Any * >( pReturn ),
1898
+                        &pInterface, pTD, 0 );
1899
+                    (*pInterface->release)( pInterface );
1900
+                    TYPELIB_DANGER_RELEASE( pTD );
1901
+                    *ppException = 0;
1902
+                    break;
1903
+                }
1904
+                TYPELIB_DANGER_RELEASE( pTD );
1905
+            }
1906
+		} // else perform queryInterface()
1907
+		default:
1908
+			// dependent dispatch
1909
+			cpp_call(
1910
+				pThis, aVtableSlot,
1911
+				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
1912
+				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
1913
+				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
1914
+				pReturn, pArgs, ppException );
1915
+		}
1916
+		break;
1917
+	}
1918
+	default:
1919
+	{
1920
+		::com::sun::star::uno::RuntimeException aExc(
1921
+			OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
1922
+			::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
1923
+		
1924
+		Type const & rExcType = ::getCppuType( &aExc );
1925
+		// binary identical null reference
1926
+		::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
1927
+	}
1928
+	}
1929
+}
1930
+
1931
+} } }
1932
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1933
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/cpp2uno.cxx
1934
@@ -0,0 +1,718 @@
1935
+/**************************************************************
1936
+ * 
1937
+ * Licensed to the Apache Software Foundation (ASF) under one
1938
+ * or more contributor license agreements.  See the NOTICE file
1939
+ * distributed with this work for additional information
1940
+ * regarding copyright ownership.  The ASF licenses this file
1941
+ * to you under the Apache License, Version 2.0 (the
1942
+ * "License"); you may not use this file except in compliance
1943
+ * with the License.  You may obtain a copy of the License at
1944
+ * 
1945
+ *   http://www.apache.org/licenses/LICENSE-2.0
1946
+ * 
1947
+ * Unless required by applicable law or agreed to in writing,
1948
+ * software distributed under the License is distributed on an
1949
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1950
+ * KIND, either express or implied.  See the License for the
1951
+ * specific language governing permissions and limitations
1952
+ * under the License.
1953
+ * 
1954
+ *************************************************************/
1955
+
1956
+
1957
+
1958
+// MARKER(update_precomp.py): autogen include statement, do not remove
1959
+#include "precompiled_bridges.hxx"
1960
+
1961
+#include <com/sun/star/uno/genfunc.hxx>
1962
+#include <uno/data.h>
1963
+#include <typelib/typedescription.hxx>
1964
+
1965
+#include "bridges/cpp_uno/shared/bridge.hxx"
1966
+#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx"
1967
+#include "bridges/cpp_uno/shared/types.hxx"
1968
+#include "bridges/cpp_uno/shared/vtablefactory.hxx"
1969
+
1970
+#include "share.hxx"
1971
+#include <stdio.h>
1972
+#include <string.h>
1973
+
1974
+
1975
+using namespace ::com::sun::star::uno;
1976
+
1977
+namespace
1978
+{
1979
+
1980
+//==================================================================================================
1981
+static typelib_TypeClass cpp2uno_call(
1982
+	bridges::cpp_uno::shared::CppInterfaceProxy * pThis,
1983
+	const typelib_TypeDescription * pMemberTypeDescr,
1984
+	typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
1985
+	sal_Int32 nParams, typelib_MethodParameter * pParams,
1986
+        void ** gpreg, void ** fpreg, void ** ovrflw,
1987
+	sal_Int64 * pRegisterReturn /* space for register return */ )
1988
+{
1989
+#ifdef CMC_DEBUG
1990
+    fprintf(stderr, "as far as cpp2uno_call\n");
1991
+#endif
1992
+
1993
+    int ng = 0; //number of gpr registers used 
1994
+    int nf = 0; //number of fpr regsiters used
1995
+       
1996
+    // gpreg:  [ret *], this, [gpr params]
1997
+    // fpreg:  [fpr params]
1998
+    // ovrflw: [gpr or fpr params (properly aligned)]
1999
+
2000
+	// return
2001
+	typelib_TypeDescription * pReturnTypeDescr = 0;
2002
+	if (pReturnTypeRef)
2003
+		TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
2004
+	
2005
+	void * pUnoReturn = 0;
2006
+	void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
2007
+	
2008
+	if (pReturnTypeDescr)
2009
+	{
2010
+		if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
2011
+		{
2012
+			pUnoReturn = pRegisterReturn; // direct way for simple types
2013
+		}
2014
+		else // complex return via ptr (pCppReturn)
2015
+		{
2016
+			pCppReturn = *(void **)gpreg;
2017
+            gpreg++;
2018
+            ng++;
2019
+			
2020
+			pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
2021
+						  ? alloca( pReturnTypeDescr->nSize )
2022
+						  : pCppReturn); // direct way
2023
+		}
2024
+	}
2025
+	// pop this
2026
+    gpreg++; 
2027
+    ng++;
2028
+
2029
+	// stack space
2030
+	OSL_ENSURE( sizeof(void *) == sizeof(sal_Int64), "### unexpected size!" );
2031
+	// parameters
2032
+	void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
2033
+	void ** pCppArgs = pUnoArgs + nParams;
2034
+	// indizes of values this have to be converted (interface conversion cpp<=>uno)
2035
+	sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams));
2036
+	// type descriptions for reconversions
2037
+	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
2038
+	
2039
+	sal_Int32 nTempIndizes = 0;
2040
+	bool bOverFlowUsed = false;
2041
+	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
2042
+	{
2043
+		const typelib_MethodParameter & rParam = pParams[nPos];
2044
+		typelib_TypeDescription * pParamTypeDescr = 0;
2045
+		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
2046
+
2047
+#ifdef CMC_DEBUG
2048
+		fprintf(stderr, "arg %d of %d\n", nPos, nParams);
2049
+#endif
2050
+
2051
+		if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) 
2052
+		{
2053
+#ifdef CMC_DEBUG
2054
+			fprintf(stderr, "simple\n");
2055
+#endif
2056
+
2057
+			switch (pParamTypeDescr->eTypeClass)
2058
+			{
2059
+				case typelib_TypeClass_FLOAT:
2060
+				case typelib_TypeClass_DOUBLE:
2061
+					if (nf < ppc64::MAX_SSE_REGS)
2062
+					{
2063
+						if (pParamTypeDescr->eTypeClass == typelib_TypeClass_FLOAT)
2064
+						{
2065
+                        	float tmp = (float) (*((double *)fpreg));
2066
+                        	(*((float *) fpreg)) = tmp;
2067
+						}
2068
+						pCppArgs[nPos] = pUnoArgs[nPos] = fpreg++;
2069
+						nf++;
2070
+					}
2071
+					else
2072
+                    {
2073
+						pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
2074
+                        bOverFlowUsed = true;
2075
+                    }
2076
+                    if (bOverFlowUsed) ovrflw++;
2077
+					break;
2078
+                case typelib_TypeClass_BYTE:
2079
+                case typelib_TypeClass_BOOLEAN:
2080
+                    if (ng < ppc64::MAX_GPR_REGS)
2081
+					{
2082
+                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + (sizeof(void*)-1));
2083
+                        ng++;
2084
+                        gpreg++;
2085
+                    }
2086
+                    else
2087
+					{
2088
+                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + (sizeof(void*)-1));
2089
+                        bOverFlowUsed = true;
2090
+                    }
2091
+                    if (bOverFlowUsed) ovrflw++;
2092
+                    break;
2093
+                case typelib_TypeClass_CHAR:
2094
+                case typelib_TypeClass_SHORT:
2095
+                case typelib_TypeClass_UNSIGNED_SHORT:
2096
+                    if (ng < ppc64::MAX_GPR_REGS)
2097
+					{
2098
+                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + (sizeof(void*)-2));
2099
+                        ng++;
2100
+                        gpreg++;
2101
+                    }
2102
+                    else
2103
+					{
2104
+                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + (sizeof(void*)-2));
2105
+                        bOverFlowUsed = true;
2106
+                    }
2107
+                    if (bOverFlowUsed) ovrflw++;
2108
+                    break;
2109
+		case typelib_TypeClass_ENUM:
2110
+                case typelib_TypeClass_LONG:
2111
+                case typelib_TypeClass_UNSIGNED_LONG:
2112
+                    if (ng < ppc64::MAX_GPR_REGS)
2113
+					{
2114
+                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + (sizeof(void*)-4));
2115
+                        ng++;
2116
+                        gpreg++;
2117
+                    }
2118
+                    else
2119
+					{
2120
+                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + (sizeof(void*)-4));
2121
+                        bOverFlowUsed = true;
2122
+                    }
2123
+                    if (bOverFlowUsed) ovrflw++;
2124
+                    break;
2125
+				default:
2126
+					if (ng < ppc64::MAX_GPR_REGS) 
2127
+					{
2128
+						pCppArgs[nPos] = pUnoArgs[nPos] = gpreg++;
2129
+						ng++;
2130
+					}
2131
+					else
2132
+                    {
2133
+						pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
2134
+                        bOverFlowUsed = true;
2135
+                    }
2136
+                    if (bOverFlowUsed) ovrflw++;
2137
+					break;
2138
+		        }
2139
+
2140
+		        // no longer needed
2141
+				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
2142
+		}
2143
+		else // ptr to complex value | ref
2144
+		{
2145
+#ifdef CMC_DEBUG
2146
+			fprintf(stderr, "complex, ng is %d\n", ng);
2147
+#endif
2148
+            void *pCppStack; //temporary stack pointer
2149
+
2150
+			if (ng < ppc64::MAX_GPR_REGS)
2151
+			{ 
2152
+		        pCppArgs[nPos] = pCppStack = *gpreg++;
2153
+			    ng++;
2154
+			}
2155
+			else
2156
+            {
2157
+			    pCppArgs[nPos] = pCppStack = *ovrflw;
2158
+                bOverFlowUsed = true;
2159
+            }
2160
+            if (bOverFlowUsed) ovrflw++;
2161
+
2162
+			if (! rParam.bIn) // is pure out
2163
+			{
2164
+				// uno out is unconstructed mem!
2165
+				pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
2166
+				pTempIndizes[nTempIndizes] = nPos;
2167
+				// will be released at reconversion
2168
+				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
2169
+			}
2170
+			// is in/inout
2171
+			else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
2172
+			{
2173
+				uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
2174
+										pCppStack, pParamTypeDescr,
2175
+										pThis->getBridge()->getCpp2Uno() );
2176
+				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
2177
+				// will be released at reconversion
2178
+				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
2179
+			}
2180
+			else // direct way
2181
+			{
2182
+				pUnoArgs[nPos] = pCppStack;
2183
+				// no longer needed
2184
+				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
2185
+			}
2186
+		}
2187
+	}
2188
+
2189
+#ifdef CMC_DEBUG
2190
+	fprintf(stderr, "end of params\n");
2191
+#endif
2192
+	
2193
+	// ExceptionHolder
2194
+	uno_Any aUnoExc; // Any will be constructed by callee
2195
+	uno_Any * pUnoExc = &aUnoExc;
2196
+
2197
+	// invoke uno dispatch call
2198
+	(*pThis->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
2199
+	
2200
+	// in case an exception occurred...
2201
+	if (pUnoExc)
2202
+	{
2203
+		// destruct temporary in/inout params
2204
+		for ( ; nTempIndizes--; )
2205
+		{
2206
+			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
2207
+			
2208
+			if (pParams[nIndex].bIn) // is in/inout => was constructed
2209
+				uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], 0 );
2210
+			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
2211
+		}
2212
+		if (pReturnTypeDescr)
2213
+			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
2214
+		
2215
+		CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc, pThis->getBridge()->getUno2Cpp() ); 
2216
+                // has to destruct the any
2217
+		// is here for dummy
2218
+		return typelib_TypeClass_VOID;
2219
+	}
2220
+	else // else no exception occurred...
2221
+	{
2222
+		// temporary params
2223
+		for ( ; nTempIndizes--; )
2224
+		{
2225
+			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
2226
+			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
2227
+			
2228
+			if (pParams[nIndex].bOut) // inout/out
2229
+			{
2230
+				// convert and assign
2231
+				uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
2232
+				uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
2233
+										pThis->getBridge()->getUno2Cpp() );
2234
+			}
2235
+			// destroy temp uno param
2236
+			uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
2237
+			
2238
+			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
2239
+		}
2240
+		// return
2241
+		if (pCppReturn) // has complex return
2242
+		{
2243
+			if (pUnoReturn != pCppReturn) // needs reconversion
2244
+			{
2245
+				uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
2246
+										pThis->getBridge()->getUno2Cpp() );
2247
+				// destroy temp uno return
2248
+				uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
2249
+			}
2250
+			// complex return ptr is set to return reg
2251
+			*(void **)pRegisterReturn = pCppReturn;
2252
+		}
2253
+		if (pReturnTypeDescr)
2254
+		{
2255
+			typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
2256
+			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
2257
+			return eRet;
2258
+		}
2259
+		else
2260
+			return typelib_TypeClass_VOID;
2261
+	}
2262
+}
2263
+
2264
+
2265
+//==================================================================================================
2266
+static typelib_TypeClass cpp_mediate(
2267
+	sal_uInt64 nOffsetAndIndex,
2268
+        void ** gpreg, void ** fpreg, long sp,
2269
+	sal_Int64 * pRegisterReturn /* space for register return */ )
2270
+{
2271
+    OSL_ENSURE( sizeof(sal_Int64)==sizeof(void *), "### unexpected!" );
2272
+
2273
+    sal_Int32 nVtableOffset = (nOffsetAndIndex >> 32);
2274
+    sal_Int32 nFunctionIndex = (nOffsetAndIndex & 0xFFFFFFFF);
2275
+
2276
+    long sf = *(long*)sp;
2277
+    void ** ovrflw = (void**)(sf + 112);
2278
+	
2279
+    // gpreg:  [ret *], this, [other gpr params]
2280
+    // fpreg:  [fpr params]
2281
+    // ovrflw: [gpr or fpr params (properly aligned)]
2282
+
2283
+    void * pThis;
2284
+    if (nFunctionIndex & 0x80000000 )
2285
+    {
2286
+	nFunctionIndex &= 0x7fffffff;
2287
+	pThis = gpreg[1];
2288
+#ifdef CMC_DEBUG
2289
+	fprintf(stderr, "pThis is gpreg[1]\n");
2290
+#endif
2291
+    }
2292
+    else
2293
+    {
2294
+	pThis = gpreg[0];
2295
+#ifdef CMC_DEBUG
2296
+	fprintf(stderr, "pThis is gpreg[0]\n");
2297
+#endif
2298
+    }
2299
+
2300
+#ifdef CMC_DEBUG
2301
+    fprintf(stderr, "pThis is %lx\n", pThis);
2302
+#endif
2303
+    
2304
+    pThis = static_cast< char * >(pThis) - nVtableOffset;
2305
+
2306
+#ifdef CMC_DEBUG
2307
+    fprintf(stderr, "pThis is now %lx\n", pThis);
2308
+#endif
2309
+
2310
+    bridges::cpp_uno::shared::CppInterfaceProxy * pCppI
2311
+	    = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy(
2312
+			pThis);
2313
+
2314
+    typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
2315
+
2316
+#ifdef CMC_DEBUG
2317
+    fprintf(stderr, "indexes are %d %d\n", nFunctionIndex, pTypeDescr->nMapFunctionIndexToMemberIndex);
2318
+#endif
2319
+	
2320
+	OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
2321
+	if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
2322
+	{
2323
+		throw RuntimeException(
2324
+            rtl::OUString::createFromAscii("illegal vtable index!"),
2325
+            (XInterface *)pThis );
2326
+	}
2327
+	
2328
+	// determine called method
2329
+	sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex];
2330
+	OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
2331
+
2332
+#ifdef CMC_DEBUG
2333
+	fprintf(stderr, "members are %d %d\n", nMemberPos, pTypeDescr->nAllMembers);
2334
+#endif
2335
+
2336
+	TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
2337
+    
2338
+	typelib_TypeClass eRet;
2339
+	switch (aMemberDescr.get()->eTypeClass)
2340
+	{
2341
+	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
2342
+	{
2343
+		if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
2344
+		{
2345
+			// is GET method
2346
+			eRet = cpp2uno_call(
2347
+				pCppI, aMemberDescr.get(),
2348
+				((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
2349
+				0, 0, // no params
2350
+				gpreg, fpreg, ovrflw, pRegisterReturn );
2351
+		}
2352
+		else
2353
+		{
2354
+			// is SET method
2355
+			typelib_MethodParameter aParam;
2356
+			aParam.pTypeRef =
2357
+				((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
2358
+			aParam.bIn		= sal_True;
2359
+			aParam.bOut		= sal_False;
2360
+			
2361
+			eRet = cpp2uno_call(
2362
+				pCppI, aMemberDescr.get(),
2363
+				0, // indicates void return
2364
+				1, &aParam,
2365
+				gpreg, fpreg, ovrflw, pRegisterReturn );
2366
+		}
2367
+		break;
2368
+	}
2369
+	case typelib_TypeClass_INTERFACE_METHOD:
2370
+	{
2371
+		// is METHOD
2372
+		switch (nFunctionIndex)
2373
+		{
2374
+		case 1: // acquire()
2375
+			pCppI->acquireProxy(); // non virtual call!
2376
+			eRet = typelib_TypeClass_VOID;
2377
+			break;
2378
+		case 2: // release()
2379
+			pCppI->releaseProxy(); // non virtual call!
2380
+			eRet = typelib_TypeClass_VOID;
2381
+			break;
2382
+		case 0: // queryInterface() opt
2383
+		{
2384
+			typelib_TypeDescription * pTD = 0;
2385
+			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() );
2386
+			if (pTD)
2387
+			{
2388
+                XInterface * pInterface = 0;
2389
+                (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)(
2390
+                    pCppI->getBridge()->getCppEnv(),
2391
+                    (void **)&pInterface, pCppI->getOid().pData, 
2392
+                    (typelib_InterfaceTypeDescription *)pTD );
2393
+			
2394
+                if (pInterface)
2395
+                {
2396
+                    ::uno_any_construct(
2397
+                        reinterpret_cast< uno_Any * >( gpreg[0] ),
2398
+                        &pInterface, pTD, cpp_acquire );
2399
+                    pInterface->release();
2400
+                    TYPELIB_DANGER_RELEASE( pTD );
2401
+                    *(void **)pRegisterReturn = gpreg[0];
2402
+                    eRet = typelib_TypeClass_ANY;
2403
+                    break;
2404
+                }
2405
+                TYPELIB_DANGER_RELEASE( pTD );
2406
+			}
2407
+		} // else perform queryInterface()
2408
+		default:
2409
+			eRet = cpp2uno_call(
2410
+				pCppI, aMemberDescr.get(),
2411
+				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
2412
+				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
2413
+				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
2414
+				gpreg, fpreg, ovrflw, pRegisterReturn );
2415
+		}
2416
+		break;
2417
+	}
2418
+	default:
2419
+	{
2420
+#ifdef CMC_DEBUG
2421
+	    fprintf(stderr, "screwed\n");
2422
+#endif
2423
+
2424
+		throw RuntimeException(
2425
+            rtl::OUString::createFromAscii("no member description found!"),
2426
+            (XInterface *)pThis );
2427
+		// is here for dummy
2428
+		eRet = typelib_TypeClass_VOID;
2429
+	}
2430
+	}
2431
+
2432
+#ifdef CMC_DEBUG
2433
+        fprintf(stderr, "end of cpp_mediate\n");
2434
+#endif
2435
+	return eRet;
2436
+}
2437
+
2438
+extern "C" void privateSnippetExecutor( ... )
2439
+{
2440
+    volatile long nOffsetAndIndex;
2441
+
2442
+    //mr %r3, %r11            # move into arg1 the 64bit value passed from OOo
2443
+    __asm__ __volatile__ (
2444
+                "mr     %0,    11\n\t"
2445
+                : "=r" (nOffsetAndIndex) : );
2446
+
2447
+    sal_uInt64 gpreg[ppc64::MAX_GPR_REGS];
2448
+    double fpreg[ppc64::MAX_SSE_REGS];
2449
+
2450
+    __asm__ __volatile__ (
2451
+        "std 3,   0(%0)\t\n"
2452
+        "std 4,   8(%0)\t\n"
2453
+        "std 5,  16(%0)\t\n"
2454
+        "std 6,  24(%0)\t\n"
2455
+        "std 7,  32(%0)\t\n"
2456
+        "std 8,  40(%0)\t\n"
2457
+        "std 9,  48(%0)\t\n"
2458
+        "std 10, 56(%0)\t\n"
2459
+        "stfd 1,   0(%1)\t\n"
2460
+        "stfd 2,   8(%1)\t\n"
2461
+        "stfd 3,  16(%1)\t\n"
2462
+        "stfd 4,  24(%1)\t\n"
2463
+        "stfd 5,  32(%1)\t\n"
2464
+        "stfd 6,  40(%1)\t\n"
2465
+        "stfd 7,  48(%1)\t\n"
2466
+        "stfd 8,  56(%1)\t\n"
2467
+        "stfd 9,  64(%1)\t\n"
2468
+        "stfd 10, 72(%1)\t\n"
2469
+        "stfd 11, 80(%1)\t\n"
2470
+        "stfd 12, 88(%1)\t\n"
2471
+        "stfd 13, 96(%1)\t\n"
2472
+	: : "r" (gpreg), "r" (fpreg) 
2473
+        : "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
2474
+          "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9",
2475
+          "fr10", "fr11", "fr12", "fr13"
2476
+    );
2477
+
2478
+    volatile long sp;
2479
+
2480
+    //stack pointer
2481
+    __asm__ __volatile__ (
2482
+                "mr     %0,    1\n\t"
2483
+                : "=r" (sp) : );
2484
+
2485
+    volatile long nRegReturn[1];
2486
+
2487
+    typelib_TypeClass aType =
2488
+        cpp_mediate( nOffsetAndIndex, (void**)gpreg, (void**)fpreg, sp, (sal_Int64*)nRegReturn);
2489
+
2490
+    switch( aType )
2491
+    {
2492
+        case typelib_TypeClass_VOID:
2493
+	    break;
2494
+        case typelib_TypeClass_BOOLEAN:
2495
+        case typelib_TypeClass_BYTE:
2496
+            __asm__( "lbz 3,%0\n\t" 
2497
+                : : "m" (nRegReturn[0]) );
2498
+            break;
2499
+        case typelib_TypeClass_CHAR:
2500
+        case typelib_TypeClass_UNSIGNED_SHORT:
2501
+            __asm__( "lhz 3,%0\n\t"
2502
+                : : "m" (nRegReturn[0]) );
2503
+            break;
2504
+        case typelib_TypeClass_SHORT:
2505
+            __asm__( "lha 3,%0\n\t"
2506
+                : : "m" (nRegReturn[0]) );
2507
+            break;
2508
+        case typelib_TypeClass_ENUM:
2509
+        case typelib_TypeClass_UNSIGNED_LONG:
2510
+            __asm__( "lwz 3,%0\n\t"
2511
+                : : "m"(nRegReturn[0]) );
2512
+            break;
2513
+        case typelib_TypeClass_LONG:
2514
+            __asm__( "lwa 3,%0\n\t"
2515
+                : : "m"(nRegReturn[0]) );
2516
+            break;
2517
+        case typelib_TypeClass_FLOAT:
2518
+            __asm__( "lfs 1,%0\n\t" 
2519
+                : : "m" (*((float*)nRegReturn)) );
2520
+            break;
2521
+        case typelib_TypeClass_DOUBLE:
2522
+            __asm__( "lfd 1,%0\n\t" 
2523
+                : : "m" (*((double*)nRegReturn)) );
2524
+            break;
2525
+        default:
2526
+            __asm__( "ld 3,%0\n\t" 
2527
+                : : "m" (nRegReturn[0]) );
2528
+            break;
2529
+    }
2530
+}
2531
+
2532
+const int codeSnippetSize = 24;
2533
+
2534
+unsigned char *  codeSnippet( unsigned char * code, sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset, 
2535
+                              bool simpleRetType)
2536
+{
2537
+#ifdef CMC_DEBUG
2538
+    fprintf(stderr,"in codeSnippet functionIndex is %x\n", nFunctionIndex);
2539
+    fprintf(stderr,"in codeSnippet vtableOffset is %x\n", nVtableOffset);
2540
+#endif
2541
+
2542
+    sal_uInt64 nOffsetAndIndex = ( ( (sal_uInt64) nVtableOffset ) << 32 ) | ( (sal_uInt64) nFunctionIndex );
2543
+
2544
+    if ( !simpleRetType )
2545
+        nOffsetAndIndex |= 0x80000000;
2546
+
2547
+    void ** raw = (void **)&code[0];
2548
+    memcpy(raw, (char*) privateSnippetExecutor, 16);
2549
+    raw[2] = (void*) nOffsetAndIndex;
2550
+#ifdef CMC_DEBUG
2551
+    fprintf(stderr, "in: offset/index is %x %x %d, %lx\n", 
2552
+	nFunctionIndex, nVtableOffset, !simpleRetType, raw[2]);
2553
+#endif
2554
+    return (code + codeSnippetSize);
2555
+}
2556
+
2557
+}
2558
+
2559
+void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const * bptr, unsigned char const * eptr)
2560
+{
2561
+    int const lineSize = 32;
2562
+    for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) {
2563
+        __asm__ volatile ("dcbst 0, %0" : : "r"(p) : "memory");
2564
+    }
2565
+    __asm__ volatile ("sync" : : : "memory");
2566
+    for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) {
2567
+        __asm__ volatile ("icbi 0, %0" : : "r"(p) : "memory");
2568
+    }
2569
+    __asm__ volatile ("isync" : : : "memory");
2570
+}
2571
+
2572
+struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; };
2573
+
2574
+bridges::cpp_uno::shared::VtableFactory::Slot *
2575
+bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block)
2576
+{
2577
+    return static_cast< Slot * >(block) + 2;
2578
+}
2579
+
2580
+sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
2581
+    sal_Int32 slotCount)
2582
+{
2583
+    return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize;
2584
+}
2585
+
2586
+bridges::cpp_uno::shared::VtableFactory::Slot *
2587
+bridges::cpp_uno::shared::VtableFactory::initializeBlock(
2588
+    void * block, sal_Int32 slotCount)
2589
+{
2590
+    Slot * slots = mapBlockToVtable(block);
2591
+    slots[-2].fn = 0;
2592
+    slots[-1].fn = 0;
2593
+    return slots + slotCount;
2594
+}
2595
+
2596
+unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
2597
+    Slot ** slots, unsigned char * code, sal_PtrDiff writetoexecdiff,
2598
+    typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
2599
+    sal_Int32 functionCount, sal_Int32 vtableOffset)
2600
+{
2601
+     (*slots) -= functionCount;
2602
+     Slot * s = *slots;
2603
+#ifdef CMC_DEBUG
2604
+    fprintf(stderr, "in addLocalFunctions functionOffset is %x\n",functionOffset);
2605
+    fprintf(stderr, "in addLocalFunctions vtableOffset is %x\n",vtableOffset);
2606
+#endif
2607
+
2608
+    for (sal_Int32 i = 0; i < type->nMembers; ++i) {
2609
+        typelib_TypeDescription * member = 0;
2610
+        TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
2611
+        OSL_ASSERT(member != 0);
2612
+        switch (member->eTypeClass) {
2613
+        case typelib_TypeClass_INTERFACE_ATTRIBUTE:
2614
+            // Getter:
2615
+            (s++)->fn = code + writetoexecdiff;
2616
+            code = codeSnippet(
2617
+                code, functionOffset++, vtableOffset,
2618
+                bridges::cpp_uno::shared::isSimpleType(
2619
+                    reinterpret_cast<
2620
+                    typelib_InterfaceAttributeTypeDescription * >(
2621
+                        member)->pAttributeTypeRef));
2622
+
2623
+            // Setter:
2624
+            if (!reinterpret_cast<
2625
+                typelib_InterfaceAttributeTypeDescription * >(
2626
+                    member)->bReadOnly)
2627
+            {
2628
+                (s++)->fn = code + writetoexecdiff;
2629
+                code = codeSnippet(code, functionOffset++, vtableOffset, true);
2630
+            }
2631
+            break;
2632
+
2633
+        case typelib_TypeClass_INTERFACE_METHOD:
2634
+            (s++)->fn = code + writetoexecdiff;
2635
+            code = codeSnippet(
2636
+                code, functionOffset++, vtableOffset,
2637
+                bridges::cpp_uno::shared::isSimpleType(
2638
+                    reinterpret_cast<
2639
+                    typelib_InterfaceMethodTypeDescription * >(
2640
+                        member)->pReturnTypeRef));
2641
+            break;
2642
+
2643
+        default:
2644
+            OSL_ASSERT(false);
2645
+            break;
2646
+        }
2647
+        TYPELIB_DANGER_RELEASE(member);
2648
+    }
2649
+    return code;
2650
+}
2651
+
2652
+/* vi:set tabstop=4 shiftwidth=4 expandtab: */
2653
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
2654
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/except.cxx
2655
@@ -0,0 +1,283 @@
2656
+/**************************************************************
2657
+ * 
2658
+ * Licensed to the Apache Software Foundation (ASF) under one
2659
+ * or more contributor license agreements.  See the NOTICE file
2660
+ * distributed with this work for additional information
2661
+ * regarding copyright ownership.  The ASF licenses this file
2662
+ * to you under the Apache License, Version 2.0 (the
2663
+ * "License"); you may not use this file except in compliance
2664
+ * with the License.  You may obtain a copy of the License at
2665
+ * 
2666
+ *   http://www.apache.org/licenses/LICENSE-2.0
2667
+ * 
2668
+ * Unless required by applicable law or agreed to in writing,
2669
+ * software distributed under the License is distributed on an
2670
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2671
+ * KIND, either express or implied.  See the License for the
2672
+ * specific language governing permissions and limitations
2673
+ * under the License.
2674
+ * 
2675
+ *************************************************************/
2676
+
2677
+
2678
+
2679
+// MARKER(update_precomp.py): autogen include statement, do not remove
2680
+#include "precompiled_bridges.hxx"
2681
+
2682
+#include <stdio.h>
2683
+#include <string.h>
2684
+#include <dlfcn.h>
2685
+#include <cxxabi.h>
2686
+#include <hash_map>
2687
+
2688
+#include <rtl/strbuf.hxx>
2689
+#include <rtl/ustrbuf.hxx>
2690
+#include <osl/diagnose.h>
2691
+#include <osl/mutex.hxx>
2692
+
2693
+#include <com/sun/star/uno/genfunc.hxx>
2694
+#include <typelib/typedescription.hxx>
2695
+#include <uno/any2.h>
2696
+
2697
+#include "share.hxx"
2698
+
2699
+
2700
+using namespace ::std;
2701
+using namespace ::osl;
2702
+using namespace ::rtl;
2703
+using namespace ::com::sun::star::uno;
2704
+using namespace ::__cxxabiv1;
2705
+
2706
+
2707
+namespace CPPU_CURRENT_NAMESPACE
2708
+{
2709
+
2710
+void dummy_can_throw_anything( char const * )
2711
+{
2712
+}
2713
+
2714
+//==================================================================================================
2715
+static OUString toUNOname( char const * p ) SAL_THROW( () )
2716
+{
2717
+#if OSL_DEBUG_LEVEL > 1
2718
+    char const * start = p;
2719
+#endif
2720
+
2721
+    // example: N3com3sun4star4lang24IllegalArgumentExceptionE
2722
+
2723
+	OUStringBuffer buf( 64 );
2724
+    OSL_ASSERT( 'N' == *p );
2725
+    ++p; // skip N
2726
+
2727
+    while ('E' != *p)
2728
+    {
2729
+        // read chars count
2730
+        long n = (*p++ - '0');
2731
+        while ('0' <= *p && '9' >= *p)
2732
+        {
2733
+            n *= 10;
2734
+            n += (*p++ - '0');
2735
+        }
2736
+        buf.appendAscii( p, n );
2737
+        p += n;
2738
+        if ('E' != *p)
2739
+            buf.append( (sal_Unicode)'.' );
2740
+    }
2741
+
2742
+#if OSL_DEBUG_LEVEL > 1
2743
+    OUString ret( buf.makeStringAndClear() );
2744
+    OString c_ret( OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ) );
2745
+    fprintf( stderr, "> toUNOname(): %s => %s\n", start, c_ret.getStr() );
2746
+    return ret;
2747
+#else
2748
+    return buf.makeStringAndClear();
2749
+#endif
2750
+}
2751
+
2752
+//==================================================================================================
2753
+class RTTI
2754
+{
2755
+    typedef hash_map< OUString, type_info *, OUStringHash > t_rtti_map;
2756
+
2757
+    Mutex m_mutex;
2758
+	t_rtti_map m_rttis;
2759
+    t_rtti_map m_generatedRttis;
2760
+
2761
+    void * m_hApp;
2762
+
2763
+public:
2764
+    RTTI() SAL_THROW( () );
2765
+    ~RTTI() SAL_THROW( () );
2766
+
2767
+    type_info * getRTTI( typelib_CompoundTypeDescription * ) SAL_THROW( () );
2768
+};
2769
+//__________________________________________________________________________________________________
2770
+RTTI::RTTI() SAL_THROW( () )
2771
+    : m_hApp( dlopen( 0, RTLD_LAZY ) )
2772
+{
2773
+}
2774
+//__________________________________________________________________________________________________
2775
+RTTI::~RTTI() SAL_THROW( () )
2776
+{
2777
+    dlclose( m_hApp );
2778
+}
2779
+
2780
+//__________________________________________________________________________________________________
2781
+type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THROW( () )
2782
+{
2783
+    type_info * rtti;
2784
+
2785
+    OUString const & unoName = *(OUString const *)&pTypeDescr->aBase.pTypeName;
2786
+
2787
+    MutexGuard guard( m_mutex );
2788
+    t_rtti_map::const_iterator iRttiFind( m_rttis.find( unoName ) );
2789
+    if (iRttiFind == m_rttis.end())
2790
+    {
2791
+        // RTTI symbol
2792
+        OStringBuffer buf( 64 );
2793
+        buf.append( RTL_CONSTASCII_STRINGPARAM("_ZTIN") );
2794
+        sal_Int32 index = 0;
2795
+        do
2796
+        {
2797
+            OUString token( unoName.getToken( 0, '.', index ) );
2798
+            buf.append( token.getLength() );
2799
+            OString c_token( OUStringToOString( token, RTL_TEXTENCODING_ASCII_US ) );
2800
+            buf.append( c_token );
2801
+        }
2802
+        while (index >= 0);
2803
+        buf.append( 'E' );
2804
+
2805
+        OString symName( buf.makeStringAndClear() );
2806
+        rtti = (type_info *)dlsym( m_hApp, symName.getStr() );
2807
+
2808
+        if (rtti)
2809
+        {
2810
+            pair< t_rtti_map::iterator, bool > insertion(
2811
+                m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
2812
+            OSL_ENSURE( insertion.second, "### inserting new rtti failed?!" );
2813
+        }
2814
+        else
2815
+        {
2816
+            // try to lookup the symbol in the generated rtti map
2817
+            t_rtti_map::const_iterator iFind( m_generatedRttis.find( unoName ) );
2818
+            if (iFind == m_generatedRttis.end())
2819
+            {
2820
+                // we must generate it !
2821
+                // symbol and rtti-name is nearly identical,
2822
+                // the symbol is prefixed with _ZTI
2823
+                char const * rttiName = symName.getStr() +4;
2824
+#if OSL_DEBUG_LEVEL > 1
2825
+                fprintf( stderr,"generated rtti for %s\n", rttiName );
2826
+#endif
2827
+                if (pTypeDescr->pBaseTypeDescription)
2828
+                {
2829
+                    // ensure availability of base
2830
+                    type_info * base_rtti = getRTTI(
2831
+                        (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription );
2832
+                    rtti = new __si_class_type_info(
2833
+                        strdup( rttiName ), (__class_type_info *)base_rtti );
2834
+                }
2835
+                else
2836
+                {
2837
+                    // this class has no base class
2838
+                    rtti = new __class_type_info( strdup( rttiName ) );
2839
+                }
2840
+
2841
+                pair< t_rtti_map::iterator, bool > insertion(
2842
+                    m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
2843
+                OSL_ENSURE( insertion.second, "### inserting new generated rtti failed?!" );
2844
+            }
2845
+            else // taking already generated rtti
2846
+            {
2847
+                rtti = iFind->second;
2848
+            }
2849
+        }
2850
+    }
2851
+    else
2852
+    {
2853
+        rtti = iRttiFind->second;
2854
+    }
2855
+
2856
+    return rtti;
2857
+}
2858
+
2859
+//--------------------------------------------------------------------------------------------------
2860
+static void deleteException( void * pExc )
2861
+{
2862
+    __cxa_exception const * header = ((__cxa_exception const *)pExc - 1);
2863
+    typelib_TypeDescription * pTD = 0;
2864
+    OUString unoName( toUNOname( header->exceptionType->name() ) );
2865
+    ::typelib_typedescription_getByName( &pTD, unoName.pData );
2866
+    OSL_ENSURE( pTD, "### unknown exception type! leaving out destruction => leaking!!!" );
2867
+    if (pTD)
2868
+    {
2869
+		::uno_destructData( pExc, pTD, cpp_release );
2870
+		::typelib_typedescription_release( pTD );
2871
+	}
2872
+}
2873
+
2874
+//==================================================================================================
2875
+void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
2876
+{
2877
+    void * pCppExc;
2878
+    type_info * rtti;
2879
+
2880
+    {
2881
+    // construct cpp exception object
2882
+	typelib_TypeDescription * pTypeDescr = 0;
2883
+	TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
2884
+    OSL_ASSERT( pTypeDescr );
2885
+    if (! pTypeDescr)
2886
+        terminate();
2887
+
2888
+	pCppExc = __cxa_allocate_exception( pTypeDescr->nSize );
2889
+	::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
2890
+
2891
+	// destruct uno exception
2892
+	::uno_any_destruct( pUnoExc, 0 );
2893
+    // avoiding locked counts
2894
+    static RTTI * s_rtti = 0;
2895
+    if (! s_rtti)
2896
+    {
2897
+        MutexGuard guard( Mutex::getGlobalMutex() );
2898
+        if (! s_rtti)
2899
+        {
2900
+#ifdef LEAK_STATIC_DATA
2901
+            s_rtti = new RTTI();
2902
+#else
2903
+            static RTTI rtti_data;
2904
+            s_rtti = &rtti_data;
2905
+#endif
2906
+        }
2907
+    }
2908
+	rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr );
2909
+    TYPELIB_DANGER_RELEASE( pTypeDescr );
2910
+    OSL_ENSURE( rtti, "### no rtti for throwing exception!" );
2911
+    if (! rtti)
2912
+        terminate();
2913
+    }
2914
+
2915
+	__cxa_throw( pCppExc, rtti, deleteException );
2916
+}
2917
+
2918
+//==================================================================================================
2919
+void fillUnoException( __cxa_exception * header, uno_Any * pExc, uno_Mapping * pCpp2Uno )
2920
+{
2921
+    OSL_ENSURE( header, "### no exception header!!!" );
2922
+    if (! header)
2923
+        terminate();
2924
+
2925
+	typelib_TypeDescription * pExcTypeDescr = 0;
2926
+    OUString unoName( toUNOname( header->exceptionType->name() ) );
2927
+	::typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData );
2928
+    OSL_ENSURE( pExcTypeDescr, "### can not get type description for exception!!!" );
2929
+    if (! pExcTypeDescr)
2930
+        terminate();
2931
+
2932
+    // construct uno exception any
2933
+    ::uno_any_constructAndConvert( pExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno );
2934
+    ::typelib_typedescription_release( pExcTypeDescr );
2935
+}
2936
+
2937
+}
2938
+
2939
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
2940
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/makefile.mk
2941
@@ -0,0 +1,75 @@
2942
+#**************************************************************
2943
+#  
2944
+#  Licensed to the Apache Software Foundation (ASF) under one
2945
+#  or more contributor license agreements.  See the NOTICE file
2946
+#  distributed with this work for additional information
2947
+#  regarding copyright ownership.  The ASF licenses this file
2948
+#  to you under the Apache License, Version 2.0 (the
2949
+#  "License"); you may not use this file except in compliance
2950
+#  with the License.  You may obtain a copy of the License at
2951
+#  
2952
+#    http://www.apache.org/licenses/LICENSE-2.0
2953
+#  
2954
+#  Unless required by applicable law or agreed to in writing,
2955
+#  software distributed under the License is distributed on an
2956
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2957
+#  KIND, either express or implied.  See the License for the
2958
+#  specific language governing permissions and limitations
2959
+#  under the License.
2960
+#  
2961
+#**************************************************************
2962
+
2963
+
2964
+
2965
+PRJ=..$/..$/..
2966
+
2967
+PRJNAME=bridges
2968
+TARGET=gcc3_uno
2969
+LIBTARGET=no
2970
+ENABLE_EXCEPTIONS=TRUE
2971
+
2972
+# --- Settings -----------------------------------------------------
2973
+
2974
+.INCLUDE :  settings.mk
2975
+
2976
+# --- Files --------------------------------------------------------
2977
+
2978
+.IF "$(COM)$(OS)$(CPU)$(COMNAME)$(CPUNAME)" == "GCCFREEBSDPgcc3POWERPC64"
2979
+
2980
+.IF "$(cppu_no_leak)" == ""
2981
+CFLAGS += -DLEAK_STATIC_DATA
2982
+.ENDIF
2983
+
2984
+# In case someone enabled the non-standard -fomit-frame-pointer which does not
2985
+# work with the .cxx sources in this directory:
2986
+CFLAGSCXX += -fno-omit-frame-pointer
2987
+
2988
+NOOPTFILES= \
2989
+	$(SLO)$/uno2cpp.obj \
2990
+	$(SLO)$/cpp2uno.obj
2991
+
2992
+CFLAGSNOOPT=-O0
2993
+
2994
+SLOFILES= \
2995
+	$(SLO)$/except.obj		\
2996
+	$(SLO)$/cpp2uno.obj		\
2997
+	$(SLO)$/uno2cpp.obj
2998
+
2999
+SHL1TARGET= $(TARGET)
3000
+
3001
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
3002
+SHL1IMPLIB=i$(TARGET)
3003
+SHL1VERSIONMAP=..$/..$/bridge_exports.map
3004
+
3005
+SHL1OBJS= $(SLOFILES)
3006
+SHL1LIBS = $(SLB)$/cpp_uno_shared.lib
3007
+
3008
+SHL1STDLIBS= \
3009
+	$(CPPULIB)			\
3010
+	$(SALLIB)
3011
+
3012
+.ENDIF
3013
+
3014
+# --- Targets ------------------------------------------------------
3015
+
3016
+.INCLUDE :  target.mk
3017
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
3018
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/share.hxx
3019
@@ -0,0 +1,92 @@
3020
+/**************************************************************
3021
+ * 
3022
+ * Licensed to the Apache Software Foundation (ASF) under one
3023
+ * or more contributor license agreements.  See the NOTICE file
3024
+ * distributed with this work for additional information
3025
+ * regarding copyright ownership.  The ASF licenses this file
3026
+ * to you under the Apache License, Version 2.0 (the
3027
+ * "License"); you may not use this file except in compliance
3028
+ * with the License.  You may obtain a copy of the License at
3029
+ * 
3030
+ *   http://www.apache.org/licenses/LICENSE-2.0
3031
+ * 
3032
+ * Unless required by applicable law or agreed to in writing,
3033
+ * software distributed under the License is distributed on an
3034
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3035
+ * KIND, either express or implied.  See the License for the
3036
+ * specific language governing permissions and limitations
3037
+ * under the License.
3038
+ * 
3039
+ *************************************************************/
3040
+
3041
+
3042
+
3043
+#include "uno/mapping.h"
3044
+
3045
+#include <typeinfo>
3046
+#include <exception>
3047
+#include <cstddef>
3048
+
3049
+namespace CPPU_CURRENT_NAMESPACE
3050
+{
3051
+
3052
+  void dummy_can_throw_anything( char const * );
3053
+
3054
+
3055
+// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
3056
+
3057
+struct _Unwind_Exception
3058
+{
3059
+    unsigned exception_class __attribute__((__mode__(__DI__)));
3060
+    void * exception_cleanup;
3061
+    unsigned private_1 __attribute__((__mode__(__word__)));
3062
+    unsigned private_2 __attribute__((__mode__(__word__)));
3063
+} __attribute__((__aligned__));
3064
+
3065
+struct __cxa_exception
3066
+{ 
3067
+    ::std::type_info *exceptionType;
3068
+    void (*exceptionDestructor)(void *); 
3069
+    
3070
+    ::std::unexpected_handler unexpectedHandler;
3071
+    ::std::terminate_handler terminateHandler;
3072
+    
3073
+    __cxa_exception *nextException;
3074
+    
3075
+    int handlerCount;
3076
+    
3077
+    int handlerSwitchValue;
3078
+    const unsigned char *actionRecord;
3079
+    const unsigned char *languageSpecificData;
3080
+    void *catchTemp;
3081
+    void *adjustedPtr;
3082
+    
3083
+    _Unwind_Exception unwindHeader;
3084
+};    
3085
+
3086
+extern "C" void *__cxa_allocate_exception(
3087
+    std::size_t thrown_size ) throw();
3088
+extern "C" void __cxa_throw (
3089
+    void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
3090
+
3091
+struct __cxa_eh_globals
3092
+{
3093
+    __cxa_exception *caughtExceptions;
3094
+    unsigned int uncaughtExceptions;
3095
+};
3096
+extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
3097
+
3098
+// -----
3099
+
3100
+//==================================================================================================
3101
+void raiseException(
3102
+    uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
3103
+//==================================================================================================
3104
+void fillUnoException(
3105
+    __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
3106
+}
3107
+
3108
+namespace ppc64
3109
+{
3110
+	enum ppclimits { MAX_GPR_REGS = 8, MAX_SSE_REGS = 13 };
3111
+}
3112
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
3113
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/uno2cpp.cxx
3114
@@ -0,0 +1,596 @@
3115
+/**************************************************************
3116
+ * 
3117
+ * Licensed to the Apache Software Foundation (ASF) under one
3118
+ * or more contributor license agreements.  See the NOTICE file
3119
+ * distributed with this work for additional information
3120
+ * regarding copyright ownership.  The ASF licenses this file
3121
+ * to you under the Apache License, Version 2.0 (the
3122
+ * "License"); you may not use this file except in compliance
3123
+ * with the License.  You may obtain a copy of the License at
3124
+ * 
3125
+ *   http://www.apache.org/licenses/LICENSE-2.0
3126
+ * 
3127
+ * Unless required by applicable law or agreed to in writing,
3128
+ * software distributed under the License is distributed on an
3129
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3130
+ * KIND, either express or implied.  See the License for the
3131
+ * specific language governing permissions and limitations
3132
+ * under the License.
3133
+ * 
3134
+ *************************************************************/
3135
+
3136
+
3137
+
3138
+// MARKER(update_precomp.py): autogen include statement, do not remove
3139
+#include "precompiled_bridges.hxx"
3140
+
3141
+#include <stdlib.h>
3142
+
3143
+#include <com/sun/star/uno/genfunc.hxx>
3144
+#include <uno/data.h>
3145
+
3146
+#include "bridges/cpp_uno/shared/bridge.hxx"
3147
+#include "bridges/cpp_uno/shared/types.hxx"
3148
+#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
3149
+#include "bridges/cpp_uno/shared/vtables.hxx"
3150
+
3151
+#include "share.hxx"
3152
+
3153
+#include <stdio.h>
3154
+#include <string.h>
3155
+
3156
+
3157
+using namespace ::rtl;
3158
+using namespace ::com::sun::star::uno;
3159
+
3160
+void MapReturn(long r3, double dret, typelib_TypeClass eTypeClass, void *pRegisterReturn)
3161
+{
3162
+    switch (eTypeClass)
3163
+    {
3164
+    case typelib_TypeClass_HYPER:
3165
+    case typelib_TypeClass_UNSIGNED_HYPER:
3166
+            *reinterpret_cast<sal_uInt64 *>( pRegisterReturn ) = r3;
3167
+            break;
3168
+    case typelib_TypeClass_LONG:
3169
+    case typelib_TypeClass_UNSIGNED_LONG:
3170
+    case typelib_TypeClass_ENUM:
3171
+            *reinterpret_cast<sal_uInt32 *>( pRegisterReturn ) = r3;
3172
+            break;
3173
+    case typelib_TypeClass_CHAR:
3174
+    case typelib_TypeClass_SHORT:
3175
+    case typelib_TypeClass_UNSIGNED_SHORT:
3176
+            *reinterpret_cast<sal_uInt16 *>( pRegisterReturn ) = (unsigned short)r3;
3177
+            break;
3178
+    case typelib_TypeClass_BOOLEAN:
3179
+    case typelib_TypeClass_BYTE:
3180
+            *reinterpret_cast<sal_uInt8 *>( pRegisterReturn ) = (unsigned char)r3;
3181
+            break;
3182
+    case typelib_TypeClass_FLOAT:
3183
+            *reinterpret_cast<float *>( pRegisterReturn ) = dret;
3184
+	    break;
3185
+    case typelib_TypeClass_DOUBLE:
3186
+            *reinterpret_cast<double *>( pRegisterReturn ) = dret;
3187
+            break;
3188
+    default:
3189
+            break;
3190
+    }
3191
+}
3192
+
3193
+namespace
3194
+{
3195
+//==================================================================================================
3196
+static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, 
3197
+	void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr, 
3198
+        sal_uInt64 *pStack, sal_uInt32 nStack,
3199
+        sal_uInt64 *pGPR, sal_uInt32 nGPR,
3200
+        double *pFPR, sal_uInt32 nFPR)
3201
+{
3202
+    // Stack, if used, must be 16-bytes aligned
3203
+    if ( nStack )
3204
+        nStack = ( nStack + 1 ) & ~1;
3205
+
3206
+    // Should not happen, but...
3207
+    if ( nFPR > ppc64::MAX_SSE_REGS )
3208
+        nFPR = ppc64::MAX_SSE_REGS;
3209
+    if ( nGPR > ppc64::MAX_GPR_REGS )
3210
+        nGPR = ppc64::MAX_GPR_REGS;
3211
+
3212
+#ifdef CMC_DEBUG
3213
+        // Let's figure out what is really going on here
3214
+        {
3215
+                fprintf( stderr, "= callVirtualMethod() =\nGPR's (%d): ", nGPR );
3216
+                for ( int i = 0; i < nGPR; ++i )
3217
+                        fprintf( stderr, "0x%lx, ", pGPR[i] );
3218
+                fprintf( stderr, "\nFPR's (%d): ", nFPR );
3219
+                for ( int i = 0; i < nFPR; ++i ) 
3220
+                        fprintf( stderr, "0x%lx (%f), ", pFPR[i], pFPR[i] );
3221
+                fprintf( stderr, "\nStack (%d): ", nStack );
3222
+                for ( int i = 0; i < nStack; ++i )
3223
+                        fprintf( stderr, "0x%lx, ", pStack[i] );
3224
+                fprintf( stderr, "\n" );
3225
+        }
3226
+#endif
3227
+
3228
+    // Load parameters to stack, if necessary
3229
+    sal_uInt64 *stack = (sal_uInt64 *) __builtin_alloca( nStack * 8 );
3230
+    memcpy( stack, pStack, nStack * 8 );
3231
+
3232
+    // Get pointer to method
3233
+    sal_uInt64 pMethod = *((sal_uInt64 *)pThis);
3234
+    pMethod += 8 * nVtableIndex;
3235
+    pMethod = *((sal_uInt64 *)pMethod);
3236
+
3237
+    typedef void (* FunctionCall )( sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64 );
3238
+    FunctionCall pFunc = (FunctionCall)pMethod;
3239
+
3240
+    volatile double dret;
3241
+
3242
+    //  fill registers
3243
+    __asm__ __volatile__ (
3244
+                "ld   3,  0(%0)\n\t"
3245
+                "ld   4,  8(%0)\n\t"
3246
+                "ld   5, 16(%0)\n\t"
3247
+                "ld   6, 24(%0)\n\t"
3248
+                "ld   7, 32(%0)\n\t"
3249
+                "ld   8, 40(%0)\n\t"
3250
+                "ld   9, 48(%0)\n\t"
3251
+                "ld  10, 56(%0)\n\t"
3252
+                "lfd  1,  0(%1)\n\t"
3253
+                "lfd  2,  8(%1)\n\t"
3254
+                "lfd  3, 16(%1)\n\t"
3255
+                "lfd  4, 24(%1)\n\t"
3256
+                "lfd  5, 32(%1)\n\t"
3257
+                "lfd  6, 40(%1)\n\t"
3258
+                "lfd  7, 48(%1)\n\t"
3259
+                "lfd  8, 56(%1)\n\t"
3260
+                "lfd  9, 64(%1)\n\t"
3261
+                "lfd 10, 72(%1)\n\t"
3262
+                "lfd 11, 80(%1)\n\t"
3263
+                "lfd 12, 88(%1)\n\t"
3264
+                "lfd 13, 96(%1)\n\t"
3265
+                : : "r" (pGPR), "r" (pFPR)
3266
+          	: "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
3267
+                  "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9",
3268
+                  "fr10", "fr11", "fr12", "fr13"
3269
+    );
3270
+
3271
+    // tell gcc that r3 to r11 are not available to it for doing the TOC and exception munge on the func call
3272
+    register sal_uInt64 r3 asm("r3");
3273
+    register sal_uInt64 r4 asm("r4");
3274
+    register sal_uInt64 r5 asm("r5");
3275
+    register sal_uInt64 r6 asm("r6");
3276
+    register sal_uInt64 r7 asm("r7");
3277
+    register sal_uInt64 r8 asm("r8");
3278
+    register sal_uInt64 r9 asm("r9");
3279
+    register sal_uInt64 r10 asm("r10");
3280
+    register sal_uInt64 r11 asm("r11");
3281
+
3282
+    (*pFunc)(r3, r4, r5, r6, r7, r8, r9, r10);
3283
+
3284
+    // get return value
3285
+    __asm__ __volatile__ (
3286
+                "mr     %1,     3\n\t"
3287
+                "mr     %2,     4\n\t"
3288
+                "fmr    %0,     1\n\t"
3289
+                : "=f" (dret), "=r" (r3), "=r" (r4) : );
3290
+
3291
+    MapReturn(r3, dret, pReturnTypeDescr->eTypeClass, pRegisterReturn);
3292
+}
3293
+
3294
+// Macros for easier insertion of values to registers or stack
3295
+// pSV - pointer to the source
3296
+// nr - order of the value [will be increased if stored to register]
3297
+// pFPR, pGPR - pointer to the registers
3298
+// pDS - pointer to the stack [will be increased if stored here]
3299
+
3300
+// The value in %xmm register is already prepared to be retrieved as a float,
3301
+// thus we treat float and double the same
3302
+#define INSERT_FLOAT( pSV, nr, pFPR, pDS, bOverflow ) \
3303
+        if ( nr < ppc64::MAX_SSE_REGS ) \
3304
+                pFPR[nr++] = *reinterpret_cast<float *>( pSV ); \
3305
+        else \
3306
+        	bOverFlow = true; \
3307
+        if (bOverFlow) \
3308
+                *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
3309
+
3310
+#define INSERT_DOUBLE( pSV, nr, pFPR, pDS, bOverflow ) \
3311
+        if ( nr < ppc64::MAX_SSE_REGS ) \
3312
+                pFPR[nr++] = *reinterpret_cast<double *>( pSV ); \
3313
+        else \
3314
+        	bOverFlow = true; \
3315
+        if (bOverFlow) \
3316
+                *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
3317
+
3318
+#define INSERT_INT64( pSV, nr, pGPR, pDS, bOverflow ) \
3319
+        if ( nr < ppc64::MAX_GPR_REGS ) \
3320
+                pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
3321
+        else \
3322
+		bOverFlow = true; \
3323
+	if (bOverFlow) \
3324
+                *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
3325
+
3326
+#define INSERT_INT32( pSV, nr, pGPR, pDS, bOverflow ) \
3327
+        if ( nr < ppc64::MAX_GPR_REGS ) \
3328
+                pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
3329
+        else \
3330
+                bOverFlow = true; \
3331
+        if (bOverFlow) \
3332
+                *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
3333
+
3334
+#define INSERT_INT16( pSV, nr, pGPR, pDS, bOverflow ) \
3335
+        if ( nr < ppc64::MAX_GPR_REGS ) \
3336
+                pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
3337
+        else \
3338
+                bOverFlow = true; \
3339
+        if (bOverFlow) \
3340
+                *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
3341
+
3342
+#define INSERT_INT8( pSV, nr, pGPR, pDS, bOverflow ) \
3343
+        if ( nr < ppc64::MAX_GPR_REGS ) \
3344
+                pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
3345
+        else \
3346
+                bOverFlow = true; \
3347
+        if (bOverFlow) \
3348
+                *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
3349
+
3350
+//================================================================================================== 
3351
+static void cpp_call(
3352
+	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
3353
+	bridges::cpp_uno::shared::VtableSlot  aVtableSlot,
3354
+	typelib_TypeDescriptionReference * pReturnTypeRef,
3355
+	sal_Int32 nParams, typelib_MethodParameter * pParams,
3356
+	void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
3357
+{
3358
+  	// max space for: [complex ret ptr], values|ptr ...
3359
+  	sal_uInt64 * pStack = (sal_uInt64 *)alloca( (nParams+3) * sizeof(sal_Int64) );
3360
+  	sal_uInt64 * pStackStart = pStack;
3361
+
3362
+	sal_uInt64 pGPR[ppc64::MAX_GPR_REGS];
3363
+	sal_uInt32 nGPR = 0;
3364
+
3365
+	double pFPR[ppc64::MAX_SSE_REGS];
3366
+	sal_uInt32 nFPR = 0;
3367
+	
3368
+	// return
3369
+	typelib_TypeDescription * pReturnTypeDescr = 0;
3370
+	TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
3371
+	OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
3372
+	
3373
+	void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
3374
+
3375
+        bool bOverFlow = false;
3376
+
3377
+	if (pReturnTypeDescr)
3378
+	{
3379
+#ifdef CMC_DEBUG
3380
+		fprintf(stderr, "return type is %d\n", pReturnTypeDescr->eTypeClass);
3381
+#endif
3382
+		if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
3383
+		{
3384
+			pCppReturn = pUnoReturn; // direct way for simple types
3385
+#ifdef CMC_DEBUG
3386
+			fprintf(stderr, "simple return\n");
3387
+#endif
3388
+		}
3389
+		else
3390
+		{
3391
+			// complex return via ptr
3392
+			pCppReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
3393
+			       ? alloca( pReturnTypeDescr->nSize ) : pUnoReturn);
3394
+#ifdef CMC_DEBUG
3395
+			fprintf(stderr, "pCppReturn/pUnoReturn is %lx/%lx", pCppReturn, pUnoReturn);
3396
+#endif
3397
+			INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack, bOverFlow );
3398
+		}
3399
+	}
3400
+	// push "this" pointer
3401
+        void * pAdjustedThisPtr = reinterpret_cast< void ** >( pThis->getCppI() ) + aVtableSlot.offset;
3402
+#ifdef CMC_DEBUG
3403
+	fprintf(stderr, "this pointer is %p\n", pAdjustedThisPtr);
3404
+#endif
3405
+	INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack, bOverFlow );
3406
+
3407
+        // Args 
3408
+        void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams );
3409
+	// indizes of values this have to be converted (interface conversion cpp<=>uno)
3410
+	sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
3411
+	// type descriptions for reconversions
3412
+	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
3413
+	
3414
+	sal_Int32 nTempIndizes   = 0;
3415
+
3416
+#ifdef CMC_DEBUG
3417
+	fprintf(stderr, "n params is %d\n", nParams);
3418
+#endif
3419
+	
3420
+	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
3421
+	{
3422
+		const typelib_MethodParameter & rParam = pParams[nPos];
3423
+		typelib_TypeDescription * pParamTypeDescr = 0;
3424
+		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
3425
+
3426
+#ifdef CMC_DEBUG
3427
+		fprintf(stderr, "param %d is %d %d %d\n", nPos, rParam.bOut, bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ),
3428
+			pParamTypeDescr->eTypeClass);
3429
+#endif
3430
+		
3431
+		if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
3432
+		{
3433
+//			uno_copyAndConvertData( pCppArgs[nPos] = alloca( 8 ), pUnoArgs[nPos], pParamTypeDescr,
3434
+			uno_copyAndConvertData( pCppArgs[nPos] = pStack, pUnoArgs[nPos], pParamTypeDescr,
3435
+									pThis->getBridge()->getUno2Cpp() );
3436
+		        switch (pParamTypeDescr->eTypeClass)
3437
+                        {
3438
+                        case typelib_TypeClass_HYPER:
3439
+                        case typelib_TypeClass_UNSIGNED_HYPER:
3440
+#ifdef CMC_DEBUG
3441
+				fprintf(stderr, "hyper is %lx\n", pCppArgs[nPos]);
3442
+#endif
3443
+                                INSERT_INT64( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
3444
+                                break;
3445
+                        case typelib_TypeClass_LONG:
3446
+                        case typelib_TypeClass_UNSIGNED_LONG:
3447
+                        case typelib_TypeClass_ENUM:
3448
+#ifdef CMC_DEBUG
3449
+				fprintf(stderr, "long is %x\n", pCppArgs[nPos]);
3450
+#endif
3451
+                                INSERT_INT32( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
3452
+                                break;
3453
+                        case typelib_TypeClass_SHORT:
3454
+                        case typelib_TypeClass_CHAR:
3455
+                        case typelib_TypeClass_UNSIGNED_SHORT:
3456
+                                INSERT_INT16( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
3457
+                                break;
3458
+                        case typelib_TypeClass_BOOLEAN:
3459
+                        case typelib_TypeClass_BYTE:
3460
+                                INSERT_INT8( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
3461
+                                break;
3462
+                        case typelib_TypeClass_FLOAT:
3463
+                                INSERT_FLOAT( pCppArgs[nPos], nFPR, pFPR, pStack, bOverFlow );
3464
+				break;
3465
+                        case typelib_TypeClass_DOUBLE:
3466
+                                INSERT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, pStack, bOverFlow );
3467
+                                break;
3468
+                        }
3469
+
3470
+                        // no longer needed
3471
+                        TYPELIB_DANGER_RELEASE( pParamTypeDescr );
3472
+	
3473
+		}
3474
+		else // ptr to complex value | ref
3475
+		{
3476
+#ifdef CMC_DEBUG
3477
+			fprintf(stderr, "complex type again %d\n", rParam.bIn);
3478
+#endif
3479
+                        if (! rParam.bIn) // is pure out
3480
+                        {
3481
+#ifdef CMC_DEBUG
3482
+				fprintf(stderr, "complex size is %d\n", pParamTypeDescr->nSize );
3483
+#endif
3484
+                                // cpp out is constructed mem, uno out is not!
3485
+                                uno_constructData(
3486
+                                        pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
3487
+                                        pParamTypeDescr ); 
3488
+                                pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
3489
+                                // will be released at reconversion
3490
+                                ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
3491
+                        }
3492
+                        // is in/inout
3493
+                        else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
3494
+                        {
3495
+#ifdef CMC_DEBUG
3496
+				fprintf(stderr, "this one\n");
3497
+#endif
3498
+                                uno_copyAndConvertData(
3499
+                                        pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
3500
+                                        pUnoArgs[nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() );
3501
+
3502
+                                pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
3503
+                                // will be released at reconversion
3504
+                                ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
3505
+                        }
3506
+                        else // direct way
3507
+                        {
3508
+#ifdef CMC_DEBUG
3509
+				fprintf(stderr, "that one, passing %lx through\n", pUnoArgs[nPos]);
3510
+#endif
3511
+                                pCppArgs[nPos] = pUnoArgs[nPos];
3512
+                                // no longer needed
3513
+                                TYPELIB_DANGER_RELEASE( pParamTypeDescr );
3514
+                        }
3515
+                        INSERT_INT64( &(pCppArgs[nPos]), nGPR, pGPR, pStack, bOverFlow );
3516
+		}
3517
+	}
3518
+  
3519
+	try
3520
+	{
3521
+               callVirtualMethod(
3522
+                        pAdjustedThisPtr, aVtableSlot.index,
3523
+                        pCppReturn, pReturnTypeDescr, 
3524
+                        pStackStart, ( pStack - pStackStart ),
3525
+                        pGPR, nGPR,
3526
+                        pFPR, nFPR );
3527
+		// NO exception occurred...
3528
+		*ppUnoExc = 0;
3529
+		
3530
+		// reconvert temporary params
3531
+		for ( ; nTempIndizes--; )
3532
+		{
3533
+			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
3534
+			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
3535
+			
3536
+			if (pParams[nIndex].bIn)
3537
+			{
3538
+				if (pParams[nIndex].bOut) // inout
3539
+				{
3540
+					uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
3541
+					uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
3542
+											pThis->getBridge()->getCpp2Uno() );
3543
+				}
3544
+			}
3545
+			else // pure out
3546
+			{
3547
+				uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
3548
+										pThis->getBridge()->getCpp2Uno() );
3549
+			}
3550
+			// destroy temp cpp param => cpp: every param was constructed
3551
+			uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
3552
+			
3553
+			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
3554
+		}
3555
+		// return value
3556
+		if (pCppReturn && pUnoReturn != pCppReturn)
3557
+		{
3558
+			uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
3559
+									pThis->getBridge()->getCpp2Uno() );
3560
+			uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
3561
+		}
3562
+	}
3563
+ 	catch (...)
3564
+ 	{
3565
+  		// fill uno exception
3566
+		fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, 
3567
+                                  *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
3568
+        
3569
+		// temporary params
3570
+		for ( ; nTempIndizes--; )
3571
+		{
3572
+			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
3573
+			// destroy temp cpp param => cpp: every param was constructed
3574
+			uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
3575
+			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
3576
+		}
3577
+		// return type
3578
+		if (pReturnTypeDescr)
3579
+			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
3580
+	}
3581
+}
3582
+
3583
+}
3584
+
3585
+namespace bridges { namespace cpp_uno { namespace shared {
3586
+
3587
+void unoInterfaceProxyDispatch(
3588
+	uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
3589
+	void * pReturn, void * pArgs[], uno_Any ** ppException )
3590
+{
3591
+	// is my surrogate
3592
+        bridges::cpp_uno::shared::UnoInterfaceProxy * pThis 
3593
+            = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy *> (pUnoI);
3594
+	typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
3595
+	
3596
+	switch (pMemberDescr->eTypeClass)
3597
+	{
3598
+	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
3599
+	{
3600
+
3601
+        VtableSlot aVtableSlot(
3602
+            getVtableSlot(
3603
+                reinterpret_cast<
3604
+                    typelib_InterfaceAttributeTypeDescription const * >(
3605
+                        pMemberDescr)));
3606
+
3607
+		if (pReturn)
3608
+		{
3609
+			// dependent dispatch
3610
+			cpp_call(
3611
+				pThis, aVtableSlot,
3612
+				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
3613
+				0, 0, // no params
3614
+				pReturn, pArgs, ppException );
3615
+		}
3616
+		else
3617
+		{
3618
+			// is SET
3619
+			typelib_MethodParameter aParam;
3620
+			aParam.pTypeRef =
3621
+				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
3622
+			aParam.bIn		= sal_True;
3623
+			aParam.bOut		= sal_False;
3624
+
3625
+			typelib_TypeDescriptionReference * pReturnTypeRef = 0;
3626
+			OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
3627
+			typelib_typedescriptionreference_new(
3628
+				&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
3629
+			
3630
+			// dependent dispatch
3631
+                        aVtableSlot.index += 1; //get then set method
3632
+			cpp_call(
3633
+				pThis, aVtableSlot,
3634
+				pReturnTypeRef,
3635
+				1, &aParam,
3636
+				pReturn, pArgs, ppException );
3637
+			
3638
+			typelib_typedescriptionreference_release( pReturnTypeRef );
3639
+		}
3640
+		
3641
+		break;
3642
+	}
3643
+	case typelib_TypeClass_INTERFACE_METHOD:
3644
+	{
3645
+
3646
+        VtableSlot aVtableSlot(
3647
+            getVtableSlot(
3648
+                reinterpret_cast<
3649
+                    typelib_InterfaceMethodTypeDescription const * >(
3650
+                        pMemberDescr)));
3651
+		switch (aVtableSlot.index)
3652
+		{
3653
+			// standard calls
3654
+		case 1: // acquire uno interface
3655
+			(*pUnoI->acquire)( pUnoI );
3656
+			*ppException = 0;
3657
+			break;
3658
+		case 2: // release uno interface
3659
+			(*pUnoI->release)( pUnoI );
3660
+			*ppException = 0;
3661
+			break;
3662
+		case 0: // queryInterface() opt
3663
+		{
3664
+			typelib_TypeDescription * pTD = 0;
3665
+			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
3666
+			if (pTD)
3667
+			{
3668
+                uno_Interface * pInterface = 0;
3669
+                (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
3670
+                    pThis->pBridge->getUnoEnv(),
3671
+                    (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
3672
+			
3673
+                if (pInterface)
3674
+                {
3675
+                    ::uno_any_construct(
3676
+                        reinterpret_cast< uno_Any * >( pReturn ),
3677
+                        &pInterface, pTD, 0 );
3678
+                    (*pInterface->release)( pInterface );
3679
+                    TYPELIB_DANGER_RELEASE( pTD );
3680
+                    *ppException = 0;
3681
+                    break;
3682
+                }
3683
+                TYPELIB_DANGER_RELEASE( pTD );
3684
+            }
3685
+		} // else perform queryInterface()
3686
+		default:
3687
+			// dependent dispatch
3688
+			cpp_call(
3689
+				pThis, aVtableSlot,
3690
+				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
3691
+				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
3692
+				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
3693
+				pReturn, pArgs, ppException );
3694
+		}
3695
+		break;
3696
+	}
3697
+	default:
3698
+	{
3699
+		::com::sun::star::uno::RuntimeException aExc(
3700
+			OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
3701
+			::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
3702
+		
3703
+		Type const & rExcType = ::getCppuType( &aExc );
3704
+		// binary identical null reference
3705
+		::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
3706
+	}
3707
+	}
3708
+}
3709
+
3710
+} } }
3711
--- desktop/source/deployment/misc/dp_platform.cxx.orig
3712
+++ desktop/source/deployment/misc/dp_platform.cxx
3713
@@ -56,6 +56,8 @@
3714
 #define PLATFORM_SOLARIS_SPARC      "solaris_sparc"
3715
 #define PLATFORM_SOLARIS_SPARC64    "solaris_sparc64"
3716
 #define PLATFORM_SOLARIS_X86        "solaris_x86"
3717
+#define PLATFORM_FREEBSD_POWERPC    "freebsd_powerpc"
3718
+#define PLATFORM_FREEBSD_POWERPC64  "freebsd_powerpc64"
3719
 #define PLATFORM_FREEBSD_X86        "freebsd_x86"
3720
 #define PLATFORM_FREEBSD_X86_64     "freebsd_x86_64"
3721
 #define PLATFORM_MACOSX_X86         "macosx_x86"
3722
@@ -164,6 +166,10 @@
3723
             ret = checkOSandCPU(OUSTR("Solaris"), OUSTR("SPARC64"));
3724
         else if (token.equals(OUSTR(PLATFORM_SOLARIS_X86)))
3725
             ret = checkOSandCPU(OUSTR("Solaris"), OUSTR("x86"));
3726
+        else if (token.equals(OUSTR(PLATFORM_FREEBSD_POWERPC)))
3727
+            ret = checkOSandCPU(OUSTR("FreeBSD"), OUSTR("PowerPC"));
3728
+        else if (token.equals(OUSTR(PLATFORM_FREEBSD_POWERPC64)))
3729
+            ret = checkOSandCPU(OUSTR("FreeBSD"), OUSTR("PowerPC64"));
3730
         else if (token.equals(OUSTR(PLATFORM_FREEBSD_X86)))
3731
             ret = checkOSandCPU(OUSTR("FreeBSD"), OUSTR("x86"));
3732
         else if (token.equals(OUSTR(PLATFORM_FREEBSD_X86_64)))
3733
--- odk/settings/platform.mk.orig
3734
+++ odk/settings/platform.mk
3735
@@ -34,6 +34,9 @@
3736
 	ifeq "$(UNOPKG_PLATFORM)" "Linux_PowerPC"
3737
 		EXTENSION_PLATFORM=linux_powerpc
3738
 	else
3739
+	ifeq "$(UNOPKG_PLATFORM)" "FreeBSD_PowerPC64"
3740
+		EXTENSION_PLATFORM=freebsd_powerpc64
3741
+	else
3742
 	ifeq "$(UNOPKG_PLATFORM)" "Linux_x86"
3743
 		EXTENSION_PLATFORM=linux_x86
3744
 	else
3745
--- odk/settings/settings.mk.orig
3746
+++ odk/settings/settings.mk
3747
@@ -507,12 +507,19 @@
3748
 else
3749
 UNOPKG_PLATFORM=FreeBSD_x86
3750
 endif
3751
+ifeq "$(PROCTYPE)" "powerpc"
3752
+UNOPKG_PLATFORM=FreeBSD_ppc
3753
+endif
3754
 endif
3755
 
3756
 ifeq "$(PROCTYPE)" "x86_64"
3757
 JAVA_PROC_TYPE=amd64
3758
 else
3759
 JAVA_PROC_TYPE=i386
3760
+endif
3761
+
3762
+ifeq "$(PROCTYPE)" "powerpc64"
3763
+JAVA_PROC_TYPE=ppc64
3764
 endif
3765
 
3766
 ifeq (kfreebsd,$(findstring kfreebsd,$(PLATFORM)))
3767
--- sal/inc/osl/endian.h.orig
3768
+++ sal/inc/osl/endian.h
3769
@@ -73,15 +73,13 @@
3770
 #ifdef FREEBSD
3771
 #   include <sys/param.h>
3772
 #   include <machine/endian.h>
3773
-#if __FreeBSD_version < 500000
3774
-#   if BYTE_ORDER == LITTLE_ENDIAN
3775
-#   	define _LITTLE_ENDIAN
3776
-#   elif BYTE_ORDER == BIG_ENDIAN
3777
-#   	define _BIG_ENDIAN
3778
-#   elif BYTE_ORDER == PDP_ENDIAN
3779
-#   	define _PDP_ENDIAN
3780
-#   endif
3781
-#endif
3782
+#   if BYTE_ORDER == LITTLE_ENDIAN
3783
+#   	undef _BIG_ENDIAN
3784
+#   elif BYTE_ORDER == BIG_ENDIAN
3785
+#   	undef _LITTLE_ENDIAN
3786
+#   elif BYTE_ORDER == PDP_ENDIAN
3787
+#   	define _PDP_ENDIAN
3788
+#   endif
3789
 #endif
3790
 
3791
 #ifdef SCO
3792
--- sal/osl/unx/system.h.orig
3793
+++ sal/osl/unx/system.h
3794
@@ -39,6 +39,7 @@
3795
 
3796
 #include <pwd.h>
3797
 
3798
+#include <osl/endian.h>
3799
 #include <netdb.h>
3800
 
3801
 #include <sys/stat.h>
3802
@@ -176,15 +177,13 @@
3803
 #   include <netinet/tcp.h>
3804
 #	define 	IORESOURCE_TRANSFER_BSD 
3805
 #   include <machine/endian.h>
3806
-#if __FreeBSD_version < 500000
3807
 #   if BYTE_ORDER == LITTLE_ENDIAN
3808
-#   	define _LITTLE_ENDIAN
3809
+#   	undef _BIG_ENDIAN
3810
 #   elif BYTE_ORDER == BIG_ENDIAN
3811
-#   	define _BIG_ENDIAN
3812
+#   	undef _LITTLE_ENDIAN
3813
 #   elif BYTE_ORDER == PDP_ENDIAN
3814
 #   	define _PDP_ENDIAN
3815
 #   endif
3816
-#endif
3817
 #	define  NO_PTHREAD_RTL
3818
 #endif
3819
 
3820
--- set_soenv.in
3821
+++ set_soenv.in
3822
@@ -396,6 +396,26 @@
3823
       $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
3824
       $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."client";
3825
       $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
3826
+   }
3827
+   elsif (($platform =~ m/^powerpc64/) && ('@SIZEOF_LONG@' eq '8'))
3828
+   {  print "Setting FreeBSD PPC64 specific values... ";
3829
+      $outfile        = "FreeBSDPPC64Env.Set"; 
3830
+      $CPU            = "P";
3831
+      $CPUNAME        = "POWERPC64";
3832
+      $OUTPATH        = "unxfbsdp";
3833
+      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64";
3834
+      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64".$ds."server";
3835
+      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64".$ds."native_threads";
3836
+   }
3837
+   elsif ($platform =~ m/powerpc/)
3838
+   {  print "Setting FreeBSD PPC specific values... ";
3839
+      $outfile        = "FreeBSDPPCEnv.Set"; 
3840
+      $CPU            = "P";
3841
+      $CPUNAME        = "POWERPC";
3842
+      $OUTPATH        = "unxfbsdp";
3843
+      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
3844
+      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."server";
3845
+      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads";
3846
    }
3847
    else
3848
    {  print "Unsupported FreeBSD architecture: $platform \n";
3849
--- solenv/gbuild/platform/freebsd.mk.orig
3850
+++ solenv/gbuild/platform/freebsd.mk
3851
@@ -36,6 +36,10 @@
3852
 CPUNAME := X86_64
3853
 endif
3854
 
3855
+ifeq ($(CPU),P)
3856
+CPUNAME := POWERPC64
3857
+endif
3858
+
3859
 # use CC/CXX if they are nondefaults
3860
 ifneq ($(origin CC),default)
3861
 gb_CC := $(CC)
3862
@@ -66,6 +70,12 @@
3863
 gb_CPUDEFS := -D$(CPUNAME)
3864
 else
3865
 gb_CPUDEFS := -DX86
3866
+endif
3867
+
3868
+ifeq ($(CPUNAME),POWERPC64)
3869
+gb_CPUDEFS := -D$(CPUNAME)
3870
+else
3871
+gb_CPUDEFS := -DPOWERPC64
3872
 endif
3873
 
3874
 gb_CFLAGS := \
3875
--- solenv/inc/libs.mk.orig
3876
+++ solenv/inc/libs.mk
3877
@@ -236,6 +236,9 @@
3878
 NEON3RDLIB=$(SOLARLIBDIR)/libneon.dylib
3879
 .ELSE
3880
 NEON3RDLIB=-lneon
3881
+.ENDIF
3882
+.IF "$(OS)" == "FREEBSD" && "$(CPUNAME)" == "POWERPC64"
3883
+JPEG3RDLIB=/usr/local/lib/libjpeg.so
3884
 .ENDIF
3885
 CURLLIB=-lcurl
3886
 SFX2LIB=-lsfx$(DLLPOSTFIX)
3887
--- solenv/inc/unx.mk.orig
3888
+++ solenv/inc/unx.mk
3889
@@ -93,6 +93,10 @@
3890
 
3891
 .IF "$(COM)$(OS)$(CPU)$(CPUNAME)" == "GCCLINUXPPOWERPC64"
3892
 .INCLUDE : unxlngppc64.mk
3893
+.ENDIF
3894
+
3895
+.IF "$(COM)$(OS)$(CPU)$(CPUNAME)" == "GCCFREEBSDPPOWERPC64"
3896
+.INCLUDE : unxfbsdp.mk
3897
 .ENDIF
3898
 
3899
 .IF "$(COM)$(OS)$(CPU)$(CPUNAME)" == "GCCLINUX3S390"
3900
--- solenv/inc/unxfbsd.mk.orig
3901
+++ solenv/inc/unxfbsd.mk
3902
@@ -36,6 +36,9 @@
3903
 .ENDIF
3904
 .IF "$(CPUNAME)" == "X86_64"
3905
 .INCLUDE : unxfbsdx.mk
3906
+.ENDIF
3907
+.IF "$(CPUNAME)" == "POWERPC64"
3908
+.INCLUDE : unxfbsdp.mk
3909
 .ENDIF
3910
 
3911
 # filter for supressing verbose messages from linker
3912
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
3913
+++ solenv/inc/unxfbsdp.mk
3914
@@ -0,0 +1,42 @@
3915
+#**************************************************************
3916
+#  
3917
+#  Licensed to the Apache Software Foundation (ASF) under one
3918
+#  or more contributor license agreements.  See the NOTICE file
3919
+#  distributed with this work for additional information
3920
+#  regarding copyright ownership.  The ASF licenses this file
3921
+#  to you under the Apache License, Version 2.0 (the
3922
+#  "License"); you may not use this file except in compliance
3923
+#  with the License.  You may obtain a copy of the License at
3924
+#  
3925
+#    http://www.apache.org/licenses/LICENSE-2.0
3926
+#  
3927
+#  Unless required by applicable law or agreed to in writing,
3928
+#  software distributed under the License is distributed on an
3929
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3930
+#  KIND, either express or implied.  See the License for the
3931
+#  specific language governing permissions and limitations
3932
+#  under the License.
3933
+#  
3934
+#**************************************************************
3935
+
3936
+
3937
+
3938
+#
3939
+# FreeBSD/ppc64 specific defines
3940
+#
3941
+
3942
+DEFAULTOPT=-Os
3943
+PICSWITCH:=-fPIC
3944
+CDEFS+=-DPOWERPC64 -DPOWERPC -DPPC
3945
+CFLAGSCXX+=-mminimal-toc
3946
+
3947
+# Compiler flags for enabling optimizations
3948
+.IF "$(PRODUCT)"!=""
3949
+CFLAGSOPT=-O2 -fno-strict-aliasing		# optimizing for products
3950
+.ELSE 	# "$(PRODUCT)"!=""
3951
+CFLAGSOPT=   					# no optimizing for non products
3952
+.ENDIF	# "$(PRODUCT)"!=""
3953
+
3954
+# platform specific identifier for shared libs
3955
+DLLPOSTFIX=
3956
+BUILD64=1
3957
--- testtools/source/bridgetest/makefile.mk.orig
3958
+++ testtools/source/bridgetest/makefile.mk
3959
@@ -134,7 +134,7 @@
3960
 
3961
 runtest : $(DLLDEST)$/uno_types.rdb $(DLLDEST)$/uno_services.rdb makefile.mk \
3962
         $(SHL1TARGETN) $(SHL2TARGETN) $(SHL3TARGETN)
3963
-.IF "$(COM)$(OS)$(CPU)" == "GCCMACOSXP" || "$(OS)$(CPU)"=="SOLARISS"
3964
+.IF "$(COM)$(OS)$(CPU)" == "GCCMACOSXP" || "$(OS)$(CPU)"=="SOLARISS" || "$(COM)$(OS)$(CPU)"=="GCCFREEBSDP"
3965
 	@echo "Mac OSX PPC GCC and Solaris fails this test! likely broken UNO bridge. Fix me."
3966
 .ELSE
3967
         cd $(DLLDEST) && $(AUGMENT_LIBRARY_PATH) $(SOLARBINDIR)/uno \

Return to bug 215130