Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 101821 | Differences between
and this patch

Collapse All | Expand All

(-)mozilla.orig/nsprpub/pr/include/md/_linux.cfg (-1 / +46 lines)
Lines 45-51 Link Here
45
45
46
#define PR_AF_INET6 10  /* same as AF_INET6 */
46
#define PR_AF_INET6 10  /* same as AF_INET6 */
47
47
48
#ifdef __powerpc__
48
#ifdef __powerpc64__
49
50
#undef  IS_LITTLE_ENDIAN
51
#define IS_BIG_ENDIAN    1
52
#define IS_64
53
54
#define PR_BYTES_PER_BYTE   1
55
#define PR_BYTES_PER_SHORT  2
56
#define PR_BYTES_PER_INT    4
57
#define PR_BYTES_PER_INT64  8
58
#define PR_BYTES_PER_LONG   8
59
#define PR_BYTES_PER_FLOAT  4
60
#define PR_BYTES_PER_DOUBLE 8
61
#define PR_BYTES_PER_WORD   8
62
#define PR_BYTES_PER_DWORD  8
63
64
#define PR_BITS_PER_BYTE    8
65
#define PR_BITS_PER_SHORT   16
66
#define PR_BITS_PER_INT     32
67
#define PR_BITS_PER_INT64   64
68
#define PR_BITS_PER_LONG    64
69
#define PR_BITS_PER_FLOAT   32
70
#define PR_BITS_PER_DOUBLE  64
71
#define PR_BITS_PER_WORD    64
72
73
#define PR_BITS_PER_BYTE_LOG2   3
74
#define PR_BITS_PER_SHORT_LOG2  4
75
#define PR_BITS_PER_INT_LOG2    5
76
#define PR_BITS_PER_INT64_LOG2  6
77
#define PR_BITS_PER_LONG_LOG2   6
78
#define PR_BITS_PER_FLOAT_LOG2  5
79
#define PR_BITS_PER_DOUBLE_LOG2 6
80
#define PR_BITS_PER_WORD_LOG2   6
81
82
#define PR_ALIGN_OF_SHORT   2
83
#define PR_ALIGN_OF_INT     4
84
#define PR_ALIGN_OF_LONG    8
85
#define PR_ALIGN_OF_INT64   8
86
#define PR_ALIGN_OF_FLOAT   4
87
#define PR_ALIGN_OF_DOUBLE  8
88
#define PR_ALIGN_OF_POINTER 8
89
#define PR_ALIGN_OF_WORD    8
90
#define PR_BYTES_PER_WORD_LOG2   3
91
#define PR_BYTES_PER_DWORD_LOG2  3
92
93
#elif defined(__powerpc__)
49
94
50
#undef  IS_LITTLE_ENDIAN
95
#undef  IS_LITTLE_ENDIAN
51
#define IS_BIG_ENDIAN    1
96
#define IS_BIG_ENDIAN    1
(-)mozilla.orig/nsprpub/pr/include/md/_linux.h (-1 / +3 lines)
Lines 43-49 Link Here
43
43
44
#define PR_LINKER_ARCH	"linux"
44
#define PR_LINKER_ARCH	"linux"
45
#define _PR_SI_SYSNAME  "LINUX"
45
#define _PR_SI_SYSNAME  "LINUX"
46
#ifdef __powerpc__
46
#ifdef __powerpc64__
47
#define _PR_SI_ARCHITECTURE "ppc64"
48
#elif defined(__powerpc__)
47
#define _PR_SI_ARCHITECTURE "ppc"
49
#define _PR_SI_ARCHITECTURE "ppc"
48
#elif defined(__alpha)
50
#elif defined(__alpha)
49
#define _PR_SI_ARCHITECTURE "alpha"
51
#define _PR_SI_ARCHITECTURE "alpha"
(-)mozilla.orig/nsprpub/pr/src/io/prprf.c (-1 / +2 lines)
Lines 51-57 Link Here
51
** Note: on some platforms va_list is defined as an array,
51
** Note: on some platforms va_list is defined as an array,
52
** and requires array notation.
52
** and requires array notation.
53
*/
53
*/
54
#if (defined(LINUX) && defined(__x86_64__))
54
#if (defined(LINUX) && defined(__x86_64__)) || \
55
    (defined(LINUX) && defined(__powerpc64__))
55
#define VARARGS_ASSIGN(foo, bar) __va_copy((foo), (bar))
56
#define VARARGS_ASSIGN(foo, bar) __va_copy((foo), (bar))
56
#elif (defined(LINUX) && defined(__powerpc__)) || \
57
#elif (defined(LINUX) && defined(__powerpc__)) || \
57
    (defined(LINUX) && defined(__s390__)) || \
58
    (defined(LINUX) && defined(__s390__)) || \
(-)mozilla.orig/security/coreconf/Linux.mk (+5 lines)
Lines 54-59 Link Here
54
	OS_REL_CFLAGS	= -DLINUX1_2 -D_XOPEN_SOURCE
54
	OS_REL_CFLAGS	= -DLINUX1_2 -D_XOPEN_SOURCE
55
	CPU_ARCH	= m68k
55
	CPU_ARCH	= m68k
56
else		
56
else		
57
ifeq ($(OS_TEST),ppc64)
58
	OS_REL_CFLAGS	= -DLINUX1_2 -D_XOPEN_SOURCE
59
	CPU_ARCH	= ppc64
60
else
57
ifeq ($(OS_TEST),ppc)
61
ifeq ($(OS_TEST),ppc)
58
	OS_REL_CFLAGS	= -DLINUX1_2 -D_XOPEN_SOURCE
62
	OS_REL_CFLAGS	= -DLINUX1_2 -D_XOPEN_SOURCE
59
	CPU_ARCH	= ppc
63
	CPU_ARCH	= ppc
Lines 117-122 Link Here
117
endif
121
endif
118
endif
122
endif
119
endif
123
endif
124
endif
120
125
121
126
122
LIBC_TAG		= _glibc
127
LIBC_TAG		= _glibc
(-)mozilla.orig/xpcom/reflect/xptcall/src/md/unix/Makefile.in (+9 lines)
Lines 243-248 Link Here
243
endif
243
endif
244
244
245
#
245
#
246
# Linux/PPC64
247
#
248
ifeq ($(OS_ARCH)$(OS_TEST),Linuxppc64)
249
CPPSRCS		:= xptcinvoke_ppc64_linux.cpp xptcstubs_ppc64_linux.cpp
250
ASFILES		:= xptcinvoke_asm_ppc64_linux.s xptcstubs_asm_ppc64_linux.s
251
AS		:= $(CC) -c -x assembler-with-cpp
252
endif
253
254
#
246
# Linux/PPC
255
# Linux/PPC
247
#
256
#
248
ifeq ($(OS_ARCH)$(OS_TEST),Linuxppc)
257
ifeq ($(OS_ARCH)$(OS_TEST),Linuxppc)
(-)mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s (+113 lines)
Line 0 Link Here
1
// -*- Mode: Asm -*-
2
//
3
// The contents of this file are subject to the Netscape Public
4
// License Version 1.1 (the "License"); you may not use this file
5
// except in compliance with the License. You may obtain a copy of
6
// the License at http://www.mozilla.org/NPL/
7
//
8
// Software distributed under the License is distributed on an "AS
9
// IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
// implied. See the License for the specific language governing
11
// rights and limitations under the License.
12
//
13
// The Original Code is mozilla.org code.
14
//
15
// The Initial Developer of the Original Code is Netscape
16
// Communications Corporation.  Portions created by Netscape are
17
// Copyright (C) 1999 Netscape Communications Corporation. All
18
// Rights Reserved.
19
//
20
// Contributor(s):
21
//   Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
22
//   beard@netscape.com (Patrick Beard)
23
//   waterson@netscape.com (Chris Waterson)
24
//   tom_gall@mac.com (Tom Gall)
25
26
.set r0,0; .set sp,1; .set RTOC,2; .set r3,3; .set r4,4
27
.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
28
.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
29
.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
30
.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
31
.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
32
.set r30,30; .set r31,31
33
.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4
34
.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9
35
.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14
36
.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19
37
.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24
38
.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
39
.set f30,30; .set f31,31
40
		      
41
        .section ".text"
42
	.align 4
43
	.globl XPTC_InvokeByIndex
44
	.type  XPTC_InvokeByIndex,@function
45
46
//
47
// XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
48
//                    PRUint32 paramCount, nsXPTCVariant* params)
49
//
50
51
XPTC_InvokeByIndex:
52
	stdu    sp,-64(sp)			// setup standard stack frame
53
	mflr    r0				// save LR
54
	std     r3,16(sp)			// r3 <= that
55
	std     r4,24(sp)			// r4 <= methodIndex
56
	std     r30,32(sp)
57
	std     r31,40(sp)
58
59
	std     r0,72(sp)			// store LR backchain
60
	mr      r31,sp
61
62
	rlwinm  r10,r5,4,0,27			// r10 = (ParamCount * 2 * 8) & ~0x0f
63
	addi    r0,r10,192			// reserve stack for GPR and FPR register save area r0 = r10 + 192 (24 registers)
64
	ld      r9,0(sp)			// r9 = backchain
65
	neg     r0,r0
66
	stdux   r9,sp,r0			// reserve stack space and save SP backchain
67
68
	addi    r3,sp,16			// r3 <= args
69
	mr      r4,r5				// r4 <= paramCount
70
	mr      r5,r6				// r5 <= params
71
	add     r6,r3,r10			// r6 <= gpregs ( == args + r10 )
72
	mr      r30,r6				// store in r30 for use later...
73
	addi    r7,r6,64			// r7 <= fpregs ( == gpregs + 32 )
74
75
	bl      invoke_copy_to_stack	// (args, paramCount, params, gpregs, fpregs)
76
77
	lfd     f1,64(r30)			// load FP registers with method parameters
78
	lfd     f2,80(r30)   
79
	lfd     f3,88(r30)  
80
	lfd     f4,96(r30)  
81
	lfd     f5,104(r30)  
82
	lfd     f6,112(r30)  
83
	lfd     f7,120(r30)  
84
	lfd     f8,128(r30)
85
86
	ld      r3,16(r31)			// r3 <= that
87
	ld      r4,24(r31)			// r4 <= methodIndex
88
	ld      r5,0(r3)			// r5 <= vtable ( == *that )
89
#if !((__GNUC__ == 3 && __GNUC_MINOR__ < 2) || __GXX_ABI_VERSION  >= 100) // G++ pre-V3 ABI
90
	addi	r4,r4,2				// skip first two vtable entries
91
#endif
92
	sldi    r4,r4,3				// convert to offset ( *= 8 )
93
	ldx     r0,r5,r4			// r0 <= methodpointer ( == vtable + offset )
94
95
        ld      r4,8(r30)			// load GP regs with method parameters
96
	ld      r5,16(r30)   
97
	ld      r6,24(r30)  
98
	ld      r7,32(r30)  
99
	ld      r8,40(r30)  
100
	ld      r9,48(r30)  
101
	ld      r10,56(r30)
102
103
	mtlr    r0				// copy methodpointer to LR    
104
	blrl					// call method
105
	
106
	ld      r30,32(r31)			// restore r30 & r31
107
	ld      r31,40(r31)
108
	
109
	ld      r11,0(sp)			// clean up the stack
110
	ld      r0,4(r11)
111
	mtlr    r0
112
	mr      sp,r11
113
	blr
(-)mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp (+140 lines)
Line 0 Link Here
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
4
 *
5
 * The contents of this file are subject to the Netscape Public License
6
 * Version 1.1 (the "License"); you may not use this file except in
7
 * compliance with the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/NPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is mozilla.org code.
16
 *
17
 * The Initial Developer of the Original Code is 
18
 * Netscape Communications Corporation.
19
 * Portions created by the Initial Developer are Copyright (C) 1998
20
 * the Initial Developer. All Rights Reserved.
21
 *
22
 * Contributor(s):
23
 *   Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
24
 *   beard@netscape.com (Patrick Beard)
25
 *   waterson@netscape.com (Chris Waterson)
26
 *   tom_gall@mac.com (Tom Gall)
27
 *
28
 * Alternatively, the contents of this file may be used under the terms of
29
 * either the GNU General Public License Version 2 or later (the "GPL"), or 
30
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31
 * in which case the provisions of the GPL or the LGPL are applicable instead
32
 * of those above. If you wish to allow use of your version of this file only
33
 * under the terms of either the GPL or the LGPL, and not to allow others to
34
 * use your version of this file under the terms of the NPL, indicate your
35
 * decision by deleting the provisions above and replace them with the notice
36
 * and other provisions required by the GPL or the LGPL. If you do not delete
37
 * the provisions above, a recipient may use your version of this file under
38
 * the terms of any one of the NPL, the GPL or the LGPL.
39
 *
40
 * ***** END LICENSE BLOCK ***** */
41
42
// Platform specific code to invoke XPCOM methods on native objects
43
44
// The purpose of XPTC_InvokeByIndex() is to map a platform
45
// indepenpent call to the platform ABI. To do that,
46
// XPTC_InvokeByIndex() has to determine the method to call via vtable
47
// access. The parameters for the method are read from the
48
// nsXPTCVariant* and prepared for th native ABI.  For the Linux/PPC
49
// ABI this means that the first 8 integral and floating point
50
// parameters are passed in registers.
51
52
#include "xptcprivate.h"
53
54
// 8 integral parameters are passed in registers
55
#define GPR_COUNT     8
56
57
// 8 floating point parameters are passed in registers, floats are
58
// promoted to doubles when passed in registers
59
#define FPR_COUNT     8
60
61
extern "C" PRUint32
62
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
63
{
64
  return PRUint32(((paramCount * 2) + 3) & ~3);
65
}
66
67
extern "C" void
68
invoke_copy_to_stack(PRUint32* d,
69
                     PRUint32 paramCount,
70
                     nsXPTCVariant* s, 
71
                     PRUint64* gpregs,
72
                     double* fpregs)
73
{
74
    PRUint32 gpr = 1; // skip one GP reg for 'that'
75
    PRUint32 fpr = 0;
76
    PRUint32 tempu32;
77
    PRUint64 tempu64;
78
    
79
    for(uint32 i = 0; i < paramCount; i++, s++) {
80
        if(s->IsPtrData())
81
            tempu32 = (PRUint32) s->ptr;
82
        else {
83
            switch(s->type) {
84
            case nsXPTType::T_FLOAT:                                  break;
85
            case nsXPTType::T_DOUBLE:                                 break;
86
            case nsXPTType::T_I8:     tempu32 = s->val.i8;            break;
87
            case nsXPTType::T_I16:    tempu32 = s->val.i16;           break;
88
            case nsXPTType::T_I32:    tempu32 = s->val.i32;           break;
89
            case nsXPTType::T_I64:    tempu64 = s->val.i64;           break;
90
            case nsXPTType::T_U8:     tempu32 = s->val.u8;            break;
91
            case nsXPTType::T_U16:    tempu32 = s->val.u16;           break;
92
            case nsXPTType::T_U32:    tempu32 = s->val.u32;           break;
93
            case nsXPTType::T_U64:    tempu64 = s->val.u64;           break;
94
            case nsXPTType::T_BOOL:   tempu32 = s->val.b;             break;
95
            case nsXPTType::T_CHAR:   tempu32 = s->val.c;             break;
96
            case nsXPTType::T_WCHAR:  tempu32 = s->val.wc;            break;
97
            default:                  tempu32 = (PRUint32) s->val.p;  break;
98
            }
99
        }
100
101
        if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
102
            if (fpr < FPR_COUNT)
103
                fpregs[fpr++]    = s->val.d;
104
            else {
105
                if ((PRUint32) d & 4) d++; // doubles are 8-byte aligned on stack
106
                *((double*) d) = s->val.d;
107
                d += 2;
108
            }
109
        }
110
        else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
111
            if (fpr < FPR_COUNT)
112
                fpregs[fpr++]   = s->val.f; // if passed in registers, floats are promoted to doubles
113
            else
114
                *((float*) d++) = s->val.f;
115
        }
116
        else if (!s->IsPtrData() && (s->type == nsXPTType::T_I64
117
                                     || s->type == nsXPTType::T_U64)) {
118
            if (gpr < GPR_COUNT) {
119
                gpregs[gpr++] = tempu64;
120
            }
121
            else {
122
                if ((PRUint32) d & 4) d++; // longlongs are 8-byte aligned on stack
123
                *((PRUint64*) d)            = tempu64;
124
                d += 2;
125
            }
126
        }
127
        else {
128
            if (gpr < GPR_COUNT)
129
                gpregs[gpr++] = tempu32;
130
            else
131
                *d++          = tempu32;
132
        }
133
        
134
    }
135
}
136
137
extern "C"
138
XPTC_PUBLIC_API(nsresult)
139
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
140
                   PRUint32 paramCount, nsXPTCVariant* params);
(-)mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s (+90 lines)
Line 0 Link Here
1
// -*- Mode: Asm -*-
2
//
3
// The contents of this file are subject to the Netscape Public
4
// License Version 1.1 (the "License"); you may not use this file
5
// except in compliance with the License. You may obtain a copy of
6
// the License at http://www.mozilla.org/NPL/
7
//
8
// Software distributed under the License is distributed on an "AS
9
// IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
// implied. See the License for the specific language governing
11
// rights and limitations under the License.
12
//
13
// The Original Code is mozilla.org code.
14
//
15
// The Initial Developer of the Original Code is Netscape
16
// Communications Corporation.  Portions created by Netscape are
17
// Copyright (C) 1999 Netscape Communications Corporation. All
18
// Rights Reserved.
19
//
20
// Contributor(s): 
21
//   Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
22
//   beard@netscape.com (Patrick Beard)
23
//   waterson@netscape.com (Chris Waterson)
24
//   tom_gall@mac.com (Tom Gall)
25
//
26
27
.set r0,0; .set sp,1; .set RTOC,2; .set r3,3; .set r4,4
28
.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
29
.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
30
.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
31
.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
32
.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
33
.set r30,30; .set r31,31
34
.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4
35
.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9
36
.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14
37
.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19
38
.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24
39
.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
40
.set f30,30; .set f31,31
41
42
        .section ".text"
43
        .align 4
44
	.globl SharedStub
45
	.type  SharedStub,@function
46
47
SharedStub:
48
        stdu	sp,-160(sp)			// room for 
49
						// linkage (16),
50
						// gprData (64),
51
						// fprData (64), 
52
						// stack alignment(16)
53
        mflr	r0
54
	std	r0,168(sp)			// save LR backchain
55
56
	std	r4,24(sp)			// save GP registers
57
	std	r5,32(sp)			// (n.b. that we don't save r3
58
	stw	r6,40(sp)			// because PrepareAndDispatch() is savvy)
59
	std	r7,48(sp)
60
	std	r8,56(sp)
61
	std	r9,64(sp)
62
	std	r10,72(sp)
63
64
	stfd	f1,80(sp)			// save FP registers
65
	stfd	f2,88(sp)
66
	stfd	f3,96(sp)
67
	stfd	f4,104(sp)
68
	stfd	f5,112(sp)
69
	stfd	f6,120(sp)
70
	stfd	f7,128(sp)
71
	stfd	f8,136(sp)
72
73
						// r3 has the 'self' pointer already
74
	
75
	mr      r4,r11				// r4 <= methodIndex selector, passed
76
						// via r11 in the nsXPTCStubBase::StubXX() call
77
	
78
	addi	r5,sp,172			// r5 <= pointer to callers args area,
79
						// beyond r3-r10/f1-f8 mapped range
80
	
81
	addi	r6,sp,16			// r6 <= gprData
82
	addi	r7,sp,80			// r7 <= fprData
83
      
84
	bl	PrepareAndDispatch	// Go!
85
    
86
	ld 	r0,168(sp)			// restore LR
87
	mtlr	r0
88
	la	sp,160(sp)			// clean up the stack
89
	blr
90
(-)mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp (+254 lines)
Line 0 Link Here
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
4
 *
5
 * The contents of this file are subject to the Netscape Public License
6
 * Version 1.1 (the "License"); you may not use this file except in
7
 * compliance with the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/NPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is mozilla.org code.
16
 *
17
 * The Initial Developer of the Original Code is 
18
 * Netscape Communications Corporation.
19
 * Portions created by the Initial Developer are Copyright (C) 1999
20
 * the Initial Developer. All Rights Reserved.
21
 *
22
 * Contributor(s):
23
 *   Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
24
 *   beard@netscape.com (Patrick Beard)
25
 *   waterson@netscape.com (Chris Waterson)
26
 *   tom_gall@mac.com (Tom Gall)
27
 *
28
 * Alternatively, the contents of this file may be used under the terms of
29
 * either the GNU General Public License Version 2 or later (the "GPL"), or 
30
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31
 * in which case the provisions of the GPL or the LGPL are applicable instead
32
 * of those above. If you wish to allow use of your version of this file only
33
 * under the terms of either the GPL or the LGPL, and not to allow others to
34
 * use your version of this file under the terms of the NPL, indicate your
35
 * decision by deleting the provisions above and replace them with the notice
36
 * and other provisions required by the GPL or the LGPL. If you do not delete
37
 * the provisions above, a recipient may use your version of this file under
38
 * the terms of any one of the NPL, the GPL or the LGPL.
39
 *
40
 * ***** END LICENSE BLOCK ***** */
41
42
// Implement shared vtbl methods.
43
44
#include "xptcprivate.h"
45
46
// The Linux/PPC ABI (aka PPC/SYSV ABI) passes the first 8 integral
47
// parameters and the first 8 floating point parameters in registers
48
// (r3-r10 and f1-f8), no stack space is allocated for these by the
49
// caller.  The rest of the parameters are passed in the callers stack
50
// area. The stack pointer has to retain 16-byte alignment, longlongs
51
// and doubles are aligned on 8-byte boundaries.
52
53
#define PARAM_BUFFER_COUNT     16
54
#define GPR_COUNT               8
55
#define FPR_COUNT               8
56
57
// PrepareAndDispatch() is called by SharedStub() and calls the actual method.
58
//
59
// - 'args[]' contains the arguments passed on stack
60
// - 'gprData[]' contains the arguments passed in integer registers
61
// - 'fprData[]' contains the arguments passed in floating point registers
62
// 
63
// The parameters are mapped into an array of type 'nsXPTCMiniVariant'
64
// and then the method gets called.
65
66
extern "C" nsresult
67
PrepareAndDispatch(nsXPTCStubBase* self,
68
                   PRUint32 methodIndex,
69
                   PRUint32* args,
70
                   PRUint64 *gprData,
71
                   double *fprData)
72
{
73
    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
74
    nsXPTCMiniVariant* dispatchParams = NULL;
75
    nsIInterfaceInfo* iface_info = NULL;
76
    const nsXPTMethodInfo* info;
77
    PRUint32 paramCount;
78
    PRUint32 i;
79
    nsresult result = NS_ERROR_FAILURE;
80
81
    NS_ASSERTION(self,"no self");
82
83
    self->GetInterfaceInfo(&iface_info);
84
    NS_ASSERTION(iface_info,"no interface info");
85
    if (! iface_info)
86
        return NS_ERROR_UNEXPECTED;
87
88
    iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
89
    NS_ASSERTION(info,"no method info");
90
    if (! info)
91
        return NS_ERROR_UNEXPECTED;
92
93
    paramCount = info->GetParamCount();
94
95
    // setup variant array pointer
96
    if(paramCount > PARAM_BUFFER_COUNT)
97
        dispatchParams = new nsXPTCMiniVariant[paramCount];
98
    else
99
        dispatchParams = paramBuffer;
100
101
    NS_ASSERTION(dispatchParams,"no place for params");
102
    if (! dispatchParams)
103
        return NS_ERROR_OUT_OF_MEMORY;
104
105
    PRUint32* ap = args;
106
    PRUint32 gpr = 1;    // skip one GPR register
107
    PRUint32 fpr = 0;
108
    PRUint32 tempu32;
109
    PRUint64 tempu64;
110
111
    for(i = 0; i < paramCount; i++) {
112
        const nsXPTParamInfo& param = info->GetParam(i);
113
        const nsXPTType& type = param.GetType();
114
        nsXPTCMiniVariant* dp = &dispatchParams[i];
115
	
116
        if (!param.IsOut() && type == nsXPTType::T_DOUBLE) {
117
            if (fpr < FPR_COUNT)
118
                dp->val.d = fprData[fpr++];
119
            else {
120
                if ((PRUint32) ap & 4) ap++; // doubles are 8-byte aligned on stack
121
                dp->val.d = *(double*) ap;
122
                ap += 2;
123
            }
124
            continue;
125
        }
126
        else if (!param.IsOut() && type == nsXPTType::T_FLOAT) {
127
            if (fpr < FPR_COUNT)
128
                dp->val.f = (float) fprData[fpr++]; // in registers floats are passed as doubles
129
            else
130
                dp->val.f = *(float*) ap++;
131
            continue;
132
        }
133
        else if (!param.IsOut() && (type == nsXPTType::T_I64
134
                                    || type == nsXPTType::T_U64)) {
135
            if (gpr < GPR_COUNT) {
136
                tempu64 = gprData[gpr++];
137
            }
138
            else {
139
                if ((PRUint32) ap & 4) ap++; // longlongs are 8-byte aligned on stack
140
                tempu64 = *(PRUint64*) ap;
141
                ap += 2;
142
            }
143
        }
144
        else {
145
            if (gpr < GPR_COUNT)
146
                tempu32 = gprData[gpr++];
147
            else
148
                tempu32 = *ap++;
149
        }
150
151
        if(param.IsOut() || !type.IsArithmetic()) {
152
            dp->val.p = (void*) tempu32;
153
            continue;
154
        }
155
156
        switch(type) {
157
        case nsXPTType::T_I8:      dp->val.i8  = (PRInt8)   tempu32; break;
158
        case nsXPTType::T_I16:     dp->val.i16 = (PRInt16)  tempu32; break;
159
        case nsXPTType::T_I32:     dp->val.i32 = (PRInt32)  tempu32; break;
160
        case nsXPTType::T_I64:     dp->val.i64 = (PRInt64)  tempu64; break;
161
        case nsXPTType::T_U8:      dp->val.u8  = (PRUint8)  tempu32; break;
162
        case nsXPTType::T_U16:     dp->val.u16 = (PRUint16) tempu32; break;
163
        case nsXPTType::T_U32:     dp->val.u32 = (PRUint32) tempu32; break;
164
        case nsXPTType::T_U64:     dp->val.u64 = (PRUint64) tempu64; break;
165
        case nsXPTType::T_BOOL:    dp->val.b   = (PRBool)   tempu32; break;
166
        case nsXPTType::T_CHAR:    dp->val.c   = (char)     tempu32; break;
167
        case nsXPTType::T_WCHAR:   dp->val.wc  = (wchar_t)  tempu32; break;
168
169
        default:
170
            NS_ASSERTION(0, "bad type");
171
            break;
172
        }
173
    }
174
175
    result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
176
177
    NS_RELEASE(iface_info);
178
179
    if (dispatchParams != paramBuffer)
180
        delete [] dispatchParams;
181
182
    return result;
183
}
184
185
// Load r11 with the constant 'n' and branch to SharedStub().
186
//
187
// XXX Yes, it's ugly that we're relying on gcc's name-mangling here;
188
// however, it's quick, dirty, and'll break when the ABI changes on
189
// us, which is what we want ;-).
190
191
#if __GXX_ABI_VERSION < 100
192
// gcc-2 version
193
# define STUB_ENTRY(n)                                       \
194
__asm__ (                                                   \
195
        ".section \".text\" \n\t"                           \
196
        ".align 4 \n\t"                                     \
197
	".globl  Stub"#n"__14nsXPTCStubBase \n\t"           \
198
	".type   Stub"#n"__14nsXPTCStubBase,@function \n\n" \
199
                                                            \
200
"Stub"#n"__14nsXPTCStubBase: \n\t"                          \
201
	"li     11,"#n" \n\t"                               \
202
	"b      SharedStub@local \n"                        \
203
);
204
#else
205
// gcc-3 version
206
//
207
// As G++3 ABI contains the length of the functionname in the mangled
208
// name, it is difficult to get a generic assembler mechanism like
209
// in the G++ 2.95 case.
210
// Create names would be like:
211
// _ZN14nsXPTCStubBase5Stub1Ev
212
// _ZN14nsXPTCStubBase6Stub12Ev
213
// _ZN14nsXPTCStubBase7Stub123Ev
214
// _ZN14nsXPTCStubBase8Stub1234Ev
215
// etc.
216
// Use assembler directives to get the names right...
217
218
# define STUB_ENTRY(n)							\
219
__asm__ (								\
220
	".align	4 \n\t"							\
221
	".if	"#n" < 10 \n\t"						\
222
	".globl	_ZN14nsXPTCStubBase5Stub"#n"Ev \n\t"			\
223
	".type	_ZN14nsXPTCStubBase5Stub"#n"Ev,@function \n\n"		\
224
"_ZN14nsXPTCStubBase5Stub"#n"Ev: \n\t"					\
225
									\
226
	".elseif "#n" < 100 \n\t"					\
227
	".globl	_ZN14nsXPTCStubBase6Stub"#n"Ev \n\t"			\
228
	".type	_ZN14nsXPTCStubBase6Stub"#n"Ev,@function \n\n"		\
229
"_ZN14nsXPTCStubBase6Stub"#n"Ev: \n\t"					\
230
									\
231
	".elseif "#n" < 1000 \n\t"					\
232
	".globl	_ZN14nsXPTCStubBase7Stub"#n"Ev \n\t"			\
233
	".type	_ZN14nsXPTCStubBase7Stub"#n"Ev,@function \n\n"		\
234
"_ZN14nsXPTCStubBase7Stub"#n"Ev: \n\t"					\
235
									\
236
	".else \n\t"							\
237
	".err	\"stub number "#n" >= 1000 not yet supported\"\n"	\
238
	".endif \n\t"							\
239
									\
240
	"li	11,"#n" \n\t"						\
241
	"b	SharedStub \n"					\
242
);
243
#endif
244
245
// "b      SharedStub@local \n"
246
247
#define SENTINEL_ENTRY(n)                            \
248
nsresult nsXPTCStubBase::Sentinel##n()               \
249
{                                                    \
250
  NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
251
  return NS_ERROR_NOT_IMPLEMENTED;                   \
252
}
253
254
#include "xptcstubsdef.inc"

Return to bug 101821