61743: add and fix NetBSD stubs (patch from martin@NetBSD.ORG)

This commit is contained in:
shaver%mozilla.org 2001-03-11 17:22:25 +00:00
Родитель ce5d19a70d
Коммит 763c4635f3
13 изменённых файлов: 1314 добавлений и 27 удалений

Просмотреть файл

@ -105,11 +105,11 @@ endif
#
# NetBSD/ARM
#
#ifeq ($(OS_ARCH),NetBSD)
#ifneq (,$(filter arm32 armv4l sa110,$(OS_TEST)))
#CPPSRCS := xptcinvoke_arm.cpp xptcstubs_arm.cpp
#endif
#endif
ifeq ($(OS_ARCH),NetBSD)
ifneq (,$(filter arm32 armv4l sa110,$(OS_TEST)))
CPPSRCS := xptcinvoke_arm_netbsd.cpp xptcstubs_arm_netbsd.cpp
endif
endif
######################################################################
# HPPA
@ -181,6 +181,11 @@ CPPSRCS := xptcinvoke_ppc_linux.cpp xptcstubs_ppc_linux.cpp
ASFILES := xptcinvoke_asm_ppc_linux.s xptcstubs_asm_ppc_linux.s
endif
ifneq (,$(filter NetBSDmacppc NetBSDbebox NetBSDofppc NetBSDprep NetBSDamigappc,$(OS_ARCH)$(OS_TEST)))
CPPSRCS := xptcinvoke_ppc_netbsd.cpp xptcstubs_ppc_netbsd.cpp
ASFILES := xptcinvoke_asm_ppc_netbsd.s xptcstubs_asm_ppc_netbsd.s
endif
ifeq ($(OS_ARCH),Rhapsody)
CPPSRCS := xptcinvoke_ppc_rhapsody.cpp xptcstubs_ppc_rhapsody.cpp
ASFILES := xptcinvoke_asm_ppc_rhapsody.s xptcstubs_asm_ppc_rhapsody.s
@ -197,6 +202,13 @@ ifneq (,$(findstring sparc,$(OS_TEST)))
CPPSRCS := xptcinvoke_sparc_solaris.cpp xptcstubs_sparc_solaris.cpp
ASFILES := xptcinvoke_asm_sparc_linux.s xptcstubs_asm_sparc_solaris.s
endif
#
# NetBSD/SPARC
#
ifeq ($(OS_ARCH)$(OS_TEST),NetBSDsparc)
CPPSRCS := xptcinvoke_sparc_netbsd.cpp xptcstubs_sparc_netbsd.cpp
ASFILES := xptcinvoke_asm_sparc_netbsd.s xptcstubs_asm_sparc_netbsd.s
endif
endif
#
# Solaris/SPARC

Просмотреть файл

@ -0,0 +1,198 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* Platform specific code to invoke XPCOM methods on native objects */
#include "xptcprivate.h"
// Remember that these 'words' are 32bit DWORDS
static PRUint32
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
{
PRUint32 result = 0;
for(PRUint32 i = 0; i < paramCount; i++, s++)
{
if(s->IsPtrData())
{
result++;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 :
case nsXPTType::T_I16 :
case nsXPTType::T_I32 :
result++;
break;
case nsXPTType::T_I64 :
result+=2;
break;
case nsXPTType::T_U8 :
case nsXPTType::T_U16 :
case nsXPTType::T_U32 :
result++;
break;
case nsXPTType::T_U64 :
result+=2;
break;
case nsXPTType::T_FLOAT :
result++;
break;
case nsXPTType::T_DOUBLE :
result+=2;
break;
case nsXPTType::T_BOOL :
case nsXPTType::T_CHAR :
case nsXPTType::T_WCHAR :
result++;
break;
default:
// all the others are plain pointer types
result++;
break;
}
}
return result;
}
static void
invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
{
for(PRUint32 i = 0; i < paramCount; i++, d++, s++)
{
if(s->IsPtrData())
{
*((void**)d) = s->ptr;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 : *((PRInt8*) d) = s->val.i8; break;
case nsXPTType::T_I16 : *((PRInt16*) d) = s->val.i16; break;
case nsXPTType::T_I32 : *((PRInt32*) d) = s->val.i32; break;
case nsXPTType::T_I64 : *((PRInt64*) d) = s->val.i64; d++; break;
case nsXPTType::T_U8 : *((PRUint8*) d) = s->val.u8; break;
case nsXPTType::T_U16 : *((PRUint16*)d) = s->val.u16; break;
case nsXPTType::T_U32 : *((PRUint32*)d) = s->val.u32; break;
case nsXPTType::T_U64 : *((PRUint64*)d) = s->val.u64; d++; break;
case nsXPTType::T_FLOAT : *((float*) d) = s->val.f; break;
case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d; d++; break;
case nsXPTType::T_BOOL : *((PRBool*) d) = s->val.b; break;
case nsXPTType::T_CHAR : *((char*) d) = s->val.c; break;
case nsXPTType::T_WCHAR : *((wchar_t*) d) = s->val.wc; break;
default:
// all the others are plain pointer types
*((void**)d) = s->val.p;
break;
}
}
}
extern "C"
struct my_params_struct {
nsISupports* that;
PRUint32 Index;
PRUint32 Count;
nsXPTCVariant* params;
PRUint32 fn_count;
PRUint32 fn_copy;
};
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params)
{
PRUint32 result;
struct my_params_struct my_params;
my_params.that = that;
my_params.Index = methodIndex;
my_params.Count = paramCount;
my_params.params = params;
my_params.fn_copy = (PRUint32) &invoke_copy_to_stack;
my_params.fn_count = (PRUint32) &invoke_count_words;
/* This is to call a given method of class that.
* The parameters are in params, the number is in paramCount.
* The routine will issue calls to count the number of words
* required for argument passing and to copy the arguments to
* the stack.
* Since APCS passes the first 3 params in r1-r3, we need to
* load the first three words from the stack and correct the stack
* pointer (sp) in the appropriate way. This means:
*
* 1.) more than 3 arguments: load r1-r3, correct sp and remember No.
* of bytes left on the stack in r4
*
* 2.) <= 2 args: load r1-r3 (we won't be causing a stack overflow I hope),
* restore sp as if nothing had happened and set the marker r4 to zero.
*
* Afterwards sp will be restored using the value in r4 (which is not a temporary register
* and will be preserved by the function/method called according to APCS [ARM Procedure
* Calling Standard]).
*
* !!! IMPORTANT !!!
* This routine makes assumptions about the vtable layout of the c++ compiler. It's implemented
* for arm-linux GNU g++ >= 2.8.1 (including egcs and gcc-2.95.[1-3])!
*
*/
__asm__ __volatile__(
"ldr r1, [%1, #12] \n\t" /* prepare to call invoke_count_words */
"ldr ip, [%1, #16] \n\t" /* r0=paramCount, r1=params */
"ldr r0, [%1, #8] \n\t"
"mov lr, pc \n\t" /* call it... */
"mov pc, ip \n\t"
"mov r4, r0, lsl #2 \n\t" /* This is the amount of bytes needed. */
"sub sp, sp, r4 \n\t" /* use stack space for the args... */
"mov r0, sp \n\t" /* prepare a pointer an the stack */
"ldr r1, [%1, #8] \n\t" /* =paramCount */
"ldr r2, [%1, #12] \n\t" /* =params */
"ldr ip, [%1, #20] \n\t" /* =invoke_copy_to_stack */
"mov lr, pc \n\t" /* copy args to the stack like the */
"mov pc, ip \n\t" /* compiler would. */
"ldr r0, [%1] \n\t" /* =that */
"ldr r1, [r0, #0] \n\t" /* get that->vtable offset */
"ldr r2, [%1, #4] \n\t"
"add r2, r1, r2, lsl #3\n\t" /* a vtable_entry(x)=8 + (8 bytes * x) */
"add r2, r2, #8 \n\t" /* with this compilers */
"ldr r3, [r2] \n\t" /* get virtual offset from vtable */
"mov r3, r3, lsl #16 \n\t"
"add r0, r0, r3, asr #16\n\t"
"ldr ip, [r2, #4] \n\t" /* get method address from vtable */
"cmp r4, #12 \n\t" /* more than 3 arguments??? */
"ldmgtia sp!, {r1, r2, r3}\n\t" /* yes: load arguments for r1-r3 */
"subgt r4, r4, #12 \n\t" /* and correct the stack pointer */
"ldmleia sp, {r1, r2, r3}\n\t" /* no: load r1-r3 from stack */
"addle sp, sp, r4 \n\t" /* and restore stack pointer */
"movle r4, #0 \n\t" /* a mark for restoring sp */
"mov lr, pc \n\t" /* call mathod */
"mov pc, ip \n\t"
"add sp, sp, r4 \n\t" /* restore stack pointer */
"mov %0, r0 \n\t" /* the result... */
: "=r" (result)
: "r" (&my_params)
: "r0", "r1", "r2", "r3", "r4", "ip", "lr"
);
return result;
}

Просмотреть файл

@ -0,0 +1,114 @@
# -*- Mode: Asm -*-
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
# beard@netscape.com (Patrick Beard)
# waterson@netscape.com (Chris Waterson)
#
.set r0,0; .set sp,1; .set RTOC,2; .set r3,3; .set r4,4
.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
.set r30,30; .set r31,31
.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4
.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9
.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14
.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19
.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24
.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
.set f30,30; .set f31,31
.section ".text"
.align 2
.globl XPTC_InvokeByIndex
.type XPTC_InvokeByIndex,@function
#
# XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
# PRUint32 paramCount, nsXPTCVariant* params)
#
XPTC_InvokeByIndex:
stwu sp,-32(sp) # setup standard stack frame
mflr r0 # save LR
stw r3,8(sp) # r3 <= that
stw r4,12(sp) # r4 <= methodIndex
stw r30,16(sp)
stw r31,20(sp)
stw r0,36(sp) # store LR backchain
mr r31,sp
rlwinm r10,r5,3,0,27 # r10 = (ParamCount * 2 * 4) & ~0x0f
addi r0,r10,96 # reserve stack for GPR and FPR register save area r0 = r10 + 96
lwz r9,0(sp) # r9 = backchain
neg r0,r0
stwux r9,sp,r0 # reserve stack sapce and save SP backchain
addi r3,sp,8 # r3 <= args
mr r4,r5 # r4 <= paramCount
mr r5,r6 # r5 <= params
add r6,r3,r10 # r6 <= gpregs ( == args + r10 )
mr r30,r6 # store in r30 for use later...
addi r7,r6,32 # r7 <= fpregs ( == gpregs + 32 )
bl invoke_copy_to_stack@local # (args, paramCount, params, gpregs, fpregs)
lfd f1,32(r30) # load FP registers with method parameters
lfd f2,40(r30)
lfd f3,48(r30)
lfd f4,56(r30)
lfd f5,64(r30)
lfd f6,72(r30)
lfd f7,80(r30)
lfd f8,88(r30)
lwz r3,8(r31) # r3 <= that
lwz r4,12(r31) # r4 <= methodIndex
lwz r5,0(r3) # r5 <= vtable ( == *that )
slwi r4,r4,3 # convert to offset ( *= 8 )
addi r4,r4,8 # skip first two vtable entries
add r4,r4,r5
lhz r0,0(r4) # virtual base offset
extsh r0,r0
add r3,r3,r0
lwz r0,4(r4) # r0 <= methodpointer ( == vtable + offset )
lwz r4,4(r30) # load GP regs with method parameters
lwz r5,8(r30)
lwz r6,12(r30)
lwz r7,16(r30)
lwz r8,20(r30)
lwz r9,24(r30)
lwz r10,28(r30)
mtlr r0 # copy methodpointer to LR
blrl # call method
lwz r30,16(r31) # restore r30 & r31
lwz r31,20(r31)
lwz r11,0(sp) # clean up the stack
lwz r0,4(r11)
mtlr r0
mr sp,r11
blr

Просмотреть файл

@ -0,0 +1,71 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* Platform specific code to invoke XPCOM methods on native objects */
.global XPTC_InvokeByIndex
/*
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);
*/
XPTC_InvokeByIndex:
save %sp,-(64 + 16),%sp ! room for the register window and
! struct pointer, rounded up to 0 % 16
mov %i2,%o0 ! paramCount
call invoke_count_words ! returns the required stack size in %o0
mov %i3,%o1 ! params
sll %o0,2,%l0 ! number of bytes
sub %sp,%l0,%sp ! create the additional stack space
mov %sp,%o0 ! pointer for copied args
add %o0,72,%o0 ! step past the register window, the
! struct result pointer and the 'this' slot
mov %i2,%o1 ! paramCount
call invoke_copy_to_stack
mov %i3,%o2 ! params
!
! calculate the target address from the vtable
!
add %i1,1,%i1 ! vTable is zero-based, index is 1 based (?)
ld [%i0],%l1 ! *that --> vTable
sll %i1,3,%i1
add %i1,%l1,%l1 ! vTable[index * 8], l1 now points to vTable entry
lduh [%l1],%l0 ! this adjustor
sll %l0,16,%l0 ! sign extend to 32 bits
sra %l0,16,%l0
add %l0,%i0,%i0 ! adjust this
ld [%l1 + 4],%l0 ! target address
.L5: ld [%sp + 88],%o5
.L4: ld [%sp + 84],%o4
.L3: ld [%sp + 80],%o3
.L2: ld [%sp + 76],%o2
.L1: ld [%sp + 72],%o1
.L0:
jmpl %l0,%o7 ! call the routine
! always have a 'this', from the incoming 'that'
mov %i0,%o0
mov %o0,%i0 ! propogate return value
ret
restore

Просмотреть файл

@ -129,6 +129,7 @@ XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
"jbsr _invoke_count_words\n\t" /* count words */
"addql #8, sp\n\t"
"lsll #2, d0\n\t" /* *= 4 */
"movl sp, a2\n\t" /* save original sp */
"subl d0, sp\n\t" /* make room for params */
"movl sp, a0\n\t"
"movl %4, sp@-\n\t"
@ -137,18 +138,22 @@ XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
"jbsr _invoke_copy_to_stack\n\t" /* copy params */
"addl #12, sp\n\t"
"movl %1, a0\n\t"
"movl a0, sp@-\n\t"
"movl a0@, a0\n\t"
"movl a0@, a1\n\t"
"movl %2, d0\n\t" /* function index */
"movl a0@(12,d0:l:8), a0\n\t"
"jbsr a0@\n\t" /* safe to not cleanup sp */
"movl d0, %0"
"movl a0, d1\n\t"
"movw a1@(8,d0:l:8), a0\n\t"
"addl a0, d1\n\t"
"movl a1@(12,d0:l:8), a1\n\t"
"movl d1, sp@-\n\t"
"jbsr a1@\n\t"
"movl a2, sp\n\t" /* restore original sp */
"movl d0, %0\n\t"
: "=g" (result) /* %0 */
: "g" (that), /* %1 */
"g" (methodIndex), /* %2 */
"g" (paramCount), /* %3 */
"g" (params) /* %4 */
: "a0", "a1", "d0", "d1", "memory"
: "a0", "a1", "a2", "d0", "d1", "memory"
);
return result;

Просмотреть файл

@ -0,0 +1,132 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
* beard@netscape.com (Patrick Beard)
* waterson@netscape.com (Chris Waterson)
*/
// Platform specific code to invoke XPCOM methods on native objects
// The purpose of XPTC_InvokeByIndex() is to map a platform
// indepenpent call to the platform ABI. To do that,
// XPTC_InvokeByIndex() has to determine the method to call via vtable
// access. The parameters for the method are read from the
// nsXPTCVariant* and prepared for th native ABI. For the Linux/PPC
// ABI this means that the first 8 integral and floating point
// parameters are passed in registers.
#include "xptcprivate.h"
// 8 integral parameters are passed in registers
#define GPR_COUNT 8
// 8 floating point parameters are passed in registers, floats are
// promoted to doubles when passed in registers
#define FPR_COUNT 8
extern "C" PRUint32
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
{
return PRUint32(((paramCount * 2) + 3) & ~3);
}
extern "C" void
invoke_copy_to_stack(PRUint32* d,
PRUint32 paramCount,
nsXPTCVariant* s,
PRUint32* gpregs,
double* fpregs)
{
PRUint32 gpr = 1; // skip one GP reg for 'that'
PRUint32 fpr = 0;
PRUint32 tempu32;
PRUint64 tempu64;
for(uint32 i = 0; i < paramCount; i++, s++) {
if(s->IsPtrData())
tempu32 = (PRUint32) s->ptr;
else {
switch(s->type) {
case nsXPTType::T_FLOAT: break;
case nsXPTType::T_DOUBLE: break;
case nsXPTType::T_I8: tempu32 = s->val.i8; break;
case nsXPTType::T_I16: tempu32 = s->val.i16; break;
case nsXPTType::T_I32: tempu32 = s->val.i32; break;
case nsXPTType::T_I64: tempu64 = s->val.i64; break;
case nsXPTType::T_U8: tempu32 = s->val.u8; break;
case nsXPTType::T_U16: tempu32 = s->val.u16; break;
case nsXPTType::T_U32: tempu32 = s->val.u32; break;
case nsXPTType::T_U64: tempu64 = s->val.u64; break;
case nsXPTType::T_BOOL: tempu32 = s->val.b; break;
case nsXPTType::T_CHAR: tempu32 = s->val.c; break;
case nsXPTType::T_WCHAR: tempu32 = s->val.wc; break;
default: tempu32 = (PRUint32) s->val.p; break;
}
}
if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
if (fpr < FPR_COUNT)
fpregs[fpr++] = s->val.d;
else {
if ((PRUint32) d & 4) d++; // doubles are 8-byte aligned on stack
*((double*) d) = s->val.d;
d += 2;
if (gpr < GPR_COUNT)
gpr += 2;
}
}
else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
if (fpr < FPR_COUNT)
fpregs[fpr++] = s->val.f; // if passed in registers, floats are promoted to doubles
else {
*((float*) d) = s->val.f;
d += 1;
if (gpr < GPR_COUNT)
gpr += 1;
}
}
else if (!s->IsPtrData() && (s->type == nsXPTType::T_I64
|| s->type == nsXPTType::T_U64)) {
if ((gpr + 1) < GPR_COUNT) {
if (gpr & 1) gpr++; // longlongs are aligned in odd/even register pairs, eg. r5/r6
*((PRUint64*) &gpregs[gpr]) = tempu64;
gpr += 2;
}
else {
if ((PRUint32) d & 4) d++; // longlongs are 8-byte aligned on stack
*((PRUint64*) d) = tempu64;
d += 2;
}
}
else {
if (gpr < GPR_COUNT)
gpregs[gpr++] = tempu32;
else
*d++ = tempu32;
}
}
}
extern "C"
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);

Просмотреть файл

@ -0,0 +1,141 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* Platform specific code to invoke XPCOM methods on native objects */
#include "xptcprivate.h"
/* solaris defines __sparc for workshop compilers and
linux defines __sparc__ */
#if !defined(__sparc) && !defined(__sparc__)
#error "This code is for Sparc only"
#endif
typedef unsigned nsXPCVariant;
extern "C" PRUint32
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
{
PRUint32 result = 0;
for(PRUint32 i = 0; i < paramCount; i++, s++)
{
if(s->IsPtrData())
{
result++;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 :
case nsXPTType::T_I16 :
case nsXPTType::T_I32 :
result++;
break;
case nsXPTType::T_I64 :
result+=2;
break;
case nsXPTType::T_U8 :
case nsXPTType::T_U16 :
case nsXPTType::T_U32 :
result++;
break;
case nsXPTType::T_U64 :
result+=2;
break;
case nsXPTType::T_FLOAT :
result++;
break;
case nsXPTType::T_DOUBLE :
result+=2;
break;
case nsXPTType::T_BOOL :
case nsXPTType::T_CHAR :
case nsXPTType::T_WCHAR :
result++;
break;
default:
// all the others are plain pointer types
result++;
break;
}
}
// nuts, I know there's a cooler way of doing this, but it's late
// now and it'll probably come to me in the morning.
if (result & 0x3) result += 4 - (result & 0x3); // ensure q-word alignment
return result;
}
extern "C" PRUint32
invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
{
/*
We need to copy the parameters for this function to locals and use them
from there since the parameters occupy the same stack space as the stack
we're trying to populate.
*/
uint32 *l_d = d;
nsXPTCVariant *l_s = s;
uint32 l_paramCount = paramCount;
uint32 regCount = 0; // return the number of registers to load from the stack
typedef struct {
uint32 hi;
uint32 lo;
} DU; // have to move 64 bit entities as 32 bit halves since
// stack slots are not guaranteed 16 byte aligned
for(uint32 i = 0; i < l_paramCount; i++, l_d++, l_s++)
{
if (regCount < 5) regCount++;
if(l_s->IsPtrData())
{
*((void**)l_d) = l_s->ptr;
continue;
}
switch(l_s->type)
{
case nsXPTType::T_I8 : *((int32*) l_d) = l_s->val.i8; break;
case nsXPTType::T_I16 : *((int32*) l_d) = l_s->val.i16; break;
case nsXPTType::T_I32 : *((int32*) l_d) = l_s->val.i32; break;
case nsXPTType::T_I64 :
case nsXPTType::T_U64 :
case nsXPTType::T_DOUBLE : *((uint32*) l_d++) = ((DU *)l_s)->hi;
if (regCount < 5) regCount++;
*((uint32*) l_d) = ((DU *)l_s)->lo;
break;
case nsXPTType::T_U8 : *((uint32*) l_d) = l_s->val.u8; break;
case nsXPTType::T_U16 : *((uint32*) l_d) = l_s->val.u16; break;
case nsXPTType::T_U32 : *((uint32*) l_d) = l_s->val.u32; break;
case nsXPTType::T_FLOAT : *((float*) l_d) = l_s->val.f; break;
case nsXPTType::T_BOOL : *((PRBool*) l_d) = l_s->val.b; break;
case nsXPTType::T_CHAR : *((uint32*) l_d) = l_s->val.c; break;
case nsXPTType::T_WCHAR : *((int32*)l_d) = l_s->val.wc; break;
default:
// all the others are plain pointer types
*((void**)l_d) = l_s->val.p;
break;
}
}
return regCount;
}

Просмотреть файл

@ -0,0 +1,130 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* Implement shared vtbl methods. */
#include "xptcprivate.h"
nsresult
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
{
#define PARAM_BUFFER_COUNT 16
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
nsXPTCMiniVariant* dispatchParams = NULL;
nsIInterfaceInfo* iface_info = NULL;
const nsXPTMethodInfo* info;
PRUint8 paramCount;
PRUint8 i;
nsresult result = NS_ERROR_FAILURE;
NS_ASSERTION(self,"no self");
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
// setup variant array pointer
if(paramCount > PARAM_BUFFER_COUNT)
dispatchParams = new nsXPTCMiniVariant[paramCount];
else
dispatchParams = paramBuffer;
NS_ASSERTION(dispatchParams,"no place for params");
PRUint32* ap = args;
for(i = 0; i < paramCount; i++, ap++)
{
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPTCMiniVariant* dp = &dispatchParams[i];
if(param.IsOut() || !type.IsArithmetic())
{
dp->val.p = (void*) *ap;
continue;
}
// else
switch(type)
{
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt8*) ap); break;
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt16*) ap); break;
case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break;
case nsXPTType::T_I64 : dp->val.i64 = *((PRInt64*) ap); ap++; break;
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint8*) ap); break;
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint16*)ap); break;
case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break;
case nsXPTType::T_U64 : dp->val.u64 = *((PRUint64*)ap); ap++; break;
case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break;
case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break;
case nsXPTType::T_CHAR : dp->val.c = *((char*) ap); break;
case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break;
default:
NS_ASSERTION(0, "bad type");
break;
}
}
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
/*
* These stubs move just move the values passed in registers onto the stack,
* so they are contiguous with values passed on the stack, and then calls
* PrepareAndDispatch() to do the dirty work.
*/
#define STUB_ENTRY(n) \
__asm__( \
".global _Stub"#n"__14nsXPTCStubBase\n\t" \
"_Stub"#n"__14nsXPTCStubBase:\n\t" \
"stmfd sp!, {r1, r2, r3} \n\t" \
"mov ip, sp \n\t" \
"stmfd sp!, {fp, ip, lr, pc} \n\t" \
"sub fp, ip, #4 \n\t" \
"mov r1, #"#n" \n\t" /* = methodIndex */ \
"add r2, sp, #16 \n\t" \
"bl _PrepareAndDispatch__FP14nsXPTCStubBaseUiPUi \n\t" \
"ldmea fp, {fp, sp, lr} \n\t" \
"add sp, sp, #12 \n\t" \
"mov pc, lr \n\t" \
);
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xptcstubsdef.inc"

Просмотреть файл

@ -0,0 +1,89 @@
# -*- Mode: Asm -*-
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
# beard@netscape.com (Patrick Beard)
# waterson@netscape.com (Chris Waterson)
#
.set r0,0; .set sp,1; .set RTOC,2; .set r3,3; .set r4,4
.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
.set r30,30; .set r31,31
.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4
.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9
.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14
.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19
.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24
.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
.set f30,30; .set f31,31
.section ".text"
.align 2
.globl SharedStub
.type SharedStub,@function
SharedStub:
stwu sp,-112(sp) # room for
# linkage (8),
# gprData (32),
# fprData (64),
# stack alignment(8)
mflr r0
stw r0,116(sp) # save LR backchain
stw r4,12(sp) # save GP registers
stw r5,16(sp) # (n.b. that we don't save r3
stw r6,20(sp) # because PrepareAndDispatch() is savvy)
stw r7,24(sp)
stw r8,28(sp)
stw r9,32(sp)
stw r10,36(sp)
stfd f1,40(sp) # save FP registers
stfd f2,48(sp)
stfd f3,56(sp)
stfd f4,64(sp)
stfd f5,72(sp)
stfd f6,80(sp)
stfd f7,88(sp)
stfd f8,96(sp)
# r3 has the 'self' pointer already
mr r4,r11 # r4 <= methodIndex selector, passed
# via r11 in the nsXPTCStubBase::StubXX() call
addi r5,sp,120 # r5 <= pointer to callers args area,
# beyond r3-r10/f1-f8 mapped range
addi r6,sp,8 # r6 <= gprData
addi r7,sp,40 # r7 <= fprData
bl PrepareAndDispatch@local # Go!
lwz r0,116(sp) # restore LR
mtlr r0
la sp,112(sp) # clean up the stack
blr

Просмотреть файл

@ -0,0 +1,65 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
.global SharedStub
/*
in the frame for the function that called SharedStub are the
rest of the parameters we need
*/
SharedStub:
! we don't create a new frame yet, but work within the frame of the calling
! function to give ourselves the other parameters we want
mov %o0, %o1 ! shuffle the index up to 2nd place
mov %i0, %o0 ! the original 'this'
add %fp, 72, %o2 ! previous stack top adjusted to the first argument slot (beyond 'this')
! save off the original incoming parameters that arrived in
! registers, the ABI guarantees the space for us to do this
st %i1, [%fp + 72]
st %i2, [%fp + 76]
st %i3, [%fp + 80]
st %i4, [%fp + 84]
st %i5, [%fp + 88]
! now we can build our own stack frame
save %sp,-(64 + 32),%sp ! room for the register window and
! struct pointer, rounded up to 0 % 32
! our function now appears to have been called
! as SharedStub(nsISupports* that, PRUint32 index, PRUint32* args)
! so we can just copy these through
mov %i0, %o0
mov %i1, %o1
mov %i2, %o2
call PrepareAndDispatch
nop
mov %o0,%i0 ! propogate return value
b .LL1
nop
.LL1:
ret
restore
.size SharedStub, .-SharedStub
.type SharedStub, #function

Просмотреть файл

@ -108,22 +108,19 @@ extern "C" {
}
}
#define STUB_ENTRY(n) \
nsresult nsXPTCStubBase::Stub##n() \
{ \
register nsresult result; \
__asm__ __volatile__( \
"lea a6@(12), a0\n\t" /* args */ \
"movl a0, sp@-\n\t" \
"movl #"#n", sp@-\n\t" /* method index */ \
"movl a6@(8), sp@-\n\t" /* this */ \
"jbsr _PrepareAndDispatch\n\t" \
"movl d0, %0" \
: "=d" (result) /* %0 */ \
: \
: "a0", "a1", "d0", "d1", "memory" ); \
return result; \
}
#define STUB_ENTRY(n) \
__asm__( \
".global _Stub"#n"__14nsXPTCStubBase\n\t" \
"_Stub"#n"__14nsXPTCStubBase:\n\t" \
"link a6,#0 \n\t" \
"lea a6@(12), a0 \n\t" /* pointer to args */ \
"movl a0, sp@- \n\t" \
"movl #"#n", sp@- \n\t" /* method index */ \
"movl a6@(8), sp@- \n\t" /* this */ \
"jbsr _PrepareAndDispatch \n\t" \
"unlk a6 \n\t" \
"rts \n\t" \
);
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \

Просмотреть файл

@ -0,0 +1,202 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
* beard@netscape.com (Patrick Beard)
* waterson@netscape.com (Chris Waterson)
*/
// Implement shared vtbl methods.
#include "xptcprivate.h"
// The Linux/PPC ABI (aka PPC/SYSV ABI) passes the first 8 integral
// parameters and the first 8 floating point parameters in registers
// (r3-r10 and f1-f8), no stack space is allocated for these by the
// caller. The rest of the parameters are passed in the callers stack
// area. The stack pointer has to retain 16-byte alignment, longlongs
// and doubles are aligned on 8-byte boundaries.
#define PARAM_BUFFER_COUNT 16
#define GPR_COUNT 8
#define FPR_COUNT 8
// PrepareAndDispatch() is called by SharedStub() and calls the actual method.
//
// - 'args[]' contains the arguments passed on stack
// - 'gprData[]' contains the arguments passed in integer registers
// - 'fprData[]' contains the arguments passed in floating point registers
//
// The parameters are mapped into an array of type 'nsXPTCMiniVariant'
// and then the method gets called.
extern "C" nsresult
PrepareAndDispatch(nsXPTCStubBase* self,
PRUint32 methodIndex,
PRUint32* args,
PRUint32 *gprData,
double *fprData)
{
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
nsXPTCMiniVariant* dispatchParams = NULL;
nsIInterfaceInfo* iface_info = NULL;
const nsXPTMethodInfo* info;
PRUint32 paramCount;
PRUint32 i;
nsresult result = NS_ERROR_FAILURE;
NS_ASSERTION(self,"no self");
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
if (! iface_info)
return NS_ERROR_UNEXPECTED;
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no method info");
if (! info)
return NS_ERROR_UNEXPECTED;
paramCount = info->GetParamCount();
// setup variant array pointer
if(paramCount > PARAM_BUFFER_COUNT)
dispatchParams = new nsXPTCMiniVariant[paramCount];
else
dispatchParams = paramBuffer;
NS_ASSERTION(dispatchParams,"no place for params");
if (! dispatchParams)
return NS_ERROR_OUT_OF_MEMORY;
PRUint32* ap = args;
PRUint32 gpr = 1; // skip one GPR register
PRUint32 fpr = 0;
PRUint32 tempu32;
PRUint64 tempu64;
for(i = 0; i < paramCount; i++) {
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPTCMiniVariant* dp = &dispatchParams[i];
if (!param.IsOut() && type == nsXPTType::T_DOUBLE) {
if (fpr < FPR_COUNT)
dp->val.d = fprData[fpr++];
else {
if ((PRUint32) ap & 4) ap++; // doubles are 8-byte aligned on stack
dp->val.d = *(double*) ap;
ap += 2;
if (gpr < GPR_COUNT)
gpr += 2;
}
continue;
}
else if (!param.IsOut() && type == nsXPTType::T_FLOAT) {
if (fpr < FPR_COUNT)
dp->val.f = (float) fprData[fpr++]; // in registers floats are passed as doubles
else {
dp->val.f = *(float*) ap;
ap += 1;
if (gpr < GPR_COUNT)
gpr += 1;
}
continue;
}
else if (!param.IsOut() && (type == nsXPTType::T_I64
|| type == nsXPTType::T_U64)) {
if (gpr & 1) gpr++; // longlongs are aligned in odd/even register pairs, eg. r5/r6
if ((gpr + 1) < GPR_COUNT) {
tempu64 = *(PRUint64*) &gprData[gpr];
gpr += 2;
}
else {
if ((PRUint32) ap & 4) ap++; // longlongs are 8-byte aligned on stack
tempu64 = *(PRUint64*) ap;
ap += 2;
}
}
else {
if (gpr < GPR_COUNT)
tempu32 = gprData[gpr++];
else
tempu32 = *ap++;
}
if(param.IsOut() || !type.IsArithmetic()) {
dp->val.p = (void*) tempu32;
continue;
}
switch(type) {
case nsXPTType::T_I8: dp->val.i8 = (PRInt8) tempu32; break;
case nsXPTType::T_I16: dp->val.i16 = (PRInt16) tempu32; break;
case nsXPTType::T_I32: dp->val.i32 = (PRInt32) tempu32; break;
case nsXPTType::T_I64: dp->val.i64 = (PRInt64) tempu64; break;
case nsXPTType::T_U8: dp->val.u8 = (PRUint8) tempu32; break;
case nsXPTType::T_U16: dp->val.u16 = (PRUint16) tempu32; break;
case nsXPTType::T_U32: dp->val.u32 = (PRUint32) tempu32; break;
case nsXPTType::T_U64: dp->val.u64 = (PRUint64) tempu64; break;
case nsXPTType::T_BOOL: dp->val.b = (PRBool) tempu32; break;
case nsXPTType::T_CHAR: dp->val.c = (char) tempu32; break;
case nsXPTType::T_WCHAR: dp->val.wc = (wchar_t) tempu32; break;
default:
NS_ASSERTION(0, "bad type");
break;
}
}
result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if (dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
// Load r11 with the constant 'n' and branch to SharedStub().
//
// XXX Yes, it's ugly that we're relying on gcc's name-mangling here;
// however, it's quick, dirty, and'll break when the ABI changes on
// us, which is what we want ;-).
#define STUB_ENTRY(n) \
__asm__ ( \
".section \".text\" \n\t" \
".align 2 \n\t" \
".globl Stub"#n"__14nsXPTCStubBase \n\t" \
".type Stub"#n"__14nsXPTCStubBase,@function \n\n" \
\
"Stub"#n"__14nsXPTCStubBase: \n\t" \
"li 11,"#n" \n\t" \
"b SharedStub@local \n" \
);
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xptcstubsdef.inc"

Просмотреть файл

@ -0,0 +1,131 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* Implement shared vtbl methods. */
#include "xptcprivate.h"
#if defined(sparc) || defined(__sparc__)
extern "C" nsresult
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, uint32* args)
{
typedef struct {
uint32 hi;
uint32 lo;
} DU; // have to move 64 bit entities as 32 bit halves since
// stack slots are not guaranteed 16 byte aligned
#define PARAM_BUFFER_COUNT 16
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
nsXPTCMiniVariant* dispatchParams = NULL;
nsIInterfaceInfo* iface_info = NULL;
const nsXPTMethodInfo* info;
PRUint8 paramCount;
PRUint8 i;
nsresult result = NS_ERROR_FAILURE;
NS_ASSERTION(self,"no self");
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
// setup variant array pointer
if(paramCount > PARAM_BUFFER_COUNT)
dispatchParams = new nsXPTCMiniVariant[paramCount];
else
dispatchParams = paramBuffer;
NS_ASSERTION(dispatchParams,"no place for params");
PRUint32* ap = args;
for(i = 0; i < paramCount; i++, ap++)
{
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPTCMiniVariant* dp = &dispatchParams[i];
if(param.IsOut() || !type.IsArithmetic())
{
dp->val.p = (void*) *ap;
continue;
}
// else
switch(type)
{
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt32*) ap); break;
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt32*) ap); break;
case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break;
case nsXPTType::T_DOUBLE :
case nsXPTType::T_U64 :
case nsXPTType::T_I64 : ((DU *)dp)->hi = ((DU *)ap)->hi;
((DU *)dp)->lo = ((DU *)ap)->lo;
ap++;
break;
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint32*) ap); break;
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint32*)ap); break;
case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break;
case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break;
case nsXPTType::T_CHAR : dp->val.c = *((PRUint32*) ap); break;
case nsXPTType::T_WCHAR : dp->val.wc = *((PRInt32*) ap); break;
default:
NS_ASSERTION(0, "bad type");
break;
}
}
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
extern "C" int SharedStub(int, int*);
#define STUB_ENTRY(n) \
nsresult nsXPTCStubBase::Stub##n() \
{ \
int dummy; /* defeat tail-call optimization */ \
return SharedStub(n, &dummy); \
}
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xptcstubsdef.inc"
#endif /* sparc || __sparc__ */