]> git.pld-linux.org Git - packages/firefox.git/blob - mozilla-firefox-amd64.patch
- just copied mozilla-amd64.patch, builds
[packages/firefox.git] / mozilla-firefox-amd64.patch
1 diff -durN mozilla.orig/config/mkdepend/imakemdep.h mozilla/config/mkdepend/imakemdep.h
2 --- mozilla.orig/config/mkdepend/imakemdep.h    1998-09-05 06:22:25.000000000 +0200
3 +++ mozilla/config/mkdepend/imakemdep.h 2005-01-01 01:18:35.345553032 +0100
4 @@ -277,6 +277,9 @@
5  # ifdef __i386__
6         "-D__i386__",
7  # endif
8 +# ifdef __x86_64__
9 +       "-D__x86_64__",
10 +# endif
11  # ifdef __GNUC__
12         "-traditional",
13  # endif
14 diff -durN mozilla.orig/directory/c-sdk/ldap/libraries/liblber/lber-int.h mozilla/directory/c-sdk/ldap/libraries/liblber/lber-int.h
15 --- mozilla.orig/directory/c-sdk/ldap/libraries/liblber/lber-int.h      2002-03-26 22:53:23.000000000 +0100
16 +++ mozilla/directory/c-sdk/ldap/libraries/liblber/lber-int.h   2005-01-01 01:18:35.344553184 +0100
17 @@ -236,23 +236,22 @@
18              (((_l)&0xff0000)>>8) + (((_l)&0xff000000)>>24))
19  #define LBER_NTOHL(_l) LBER_HTONL(_l)
20  
21 -#elif !defined(__alpha) || defined(VMS)
22 +#elif !defined(__x86_64__) && (!defined(__alpha) || defined(VMS))
23  
24  #define LBER_HTONL( l )        htonl( l )
25  #define LBER_NTOHL( l )        ntohl( l )
26  
27  #else /* __alpha */
28  /*
29 - * htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
30 - * lower-order 32-bits of a (64-bit) long, so we define correct versions
31 - * here.
32 + * htonl and ntohl on the 64-bit UNIX platforms only swap the lower-order
33 + * 32-bits of a (64-bit) long, so we define correct versions here.
34   */
35  #define LBER_HTONL( l )        (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
36                         | htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
37  
38  #define LBER_NTOHL( l )        (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
39                         | ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
40 -#endif /* __alpha */
41 +#endif /* __alpha || __x86_64__ */
42  
43  
44  /* function prototypes */
45 diff -durN mozilla.orig/nsprpub/configure mozilla/nsprpub/configure
46 --- mozilla.orig/nsprpub/configure      2003-08-30 02:18:12.000000000 +0200
47 +++ mozilla/nsprpub/configure   2005-01-01 01:18:35.337554248 +0100
48 @@ -3729,6 +3729,9 @@
49      ia64)
50          PR_MD_ASFILES=os_Linux_ia64.s
51          ;;
52 +    x86_64)
53 +        PR_MD_ASFILES=os_Linux_x86_64.s
54 +        ;;
55      m68k)
56          CFLAGS="$CFLAGS -m68020-60"
57          CXXFLAGS="$CXXFLAGS -m68020-60"
58 diff -durN mozilla.orig/nsprpub/configure.in mozilla/nsprpub/configure.in
59 --- mozilla.orig/nsprpub/configure.in   2003-08-30 02:18:18.000000000 +0200
60 +++ mozilla/nsprpub/configure.in        2005-01-01 01:18:35.326555920 +0100
61 @@ -1218,6 +1218,9 @@
62      ia64)
63          PR_MD_ASFILES=os_Linux_ia64.s
64          ;;
65 +    x86_64)
66 +        PR_MD_ASFILES=os_Linux_x86_64.s
67 +        ;;
68      m68k)
69          CFLAGS="$CFLAGS -m68020-60"
70          CXXFLAGS="$CXXFLAGS -m68020-60"
71 diff -durN mozilla.orig/nsprpub/pr/include/md/_linux.cfg mozilla/nsprpub/pr/include/md/_linux.cfg
72 --- mozilla.orig/nsprpub/pr/include/md/_linux.cfg       2003-02-27 00:53:38.000000000 +0100
73 +++ mozilla/nsprpub/pr/include/md/_linux.cfg    2005-01-01 01:18:35.323556376 +0100
74 @@ -182,6 +182,52 @@
75  #define PR_BYTES_PER_WORD_LOG2  3
76  #define PR_BYTES_PER_DWORD_LOG2 3
77  
78 +#elif defined(__x86_64__)
79 +
80 +#define IS_LITTLE_ENDIAN 1
81 +#undef  IS_BIG_ENDIAN
82 +#define IS_64
83 +
84 +#define PR_BYTES_PER_BYTE   1
85 +#define PR_BYTES_PER_SHORT  2
86 +#define PR_BYTES_PER_INT    4
87 +#define PR_BYTES_PER_INT64  8
88 +#define PR_BYTES_PER_LONG   8
89 +#define PR_BYTES_PER_FLOAT  4
90 +#define PR_BYTES_PER_DOUBLE 8
91 +#define PR_BYTES_PER_WORD   8
92 +#define PR_BYTES_PER_DWORD  8
93 +
94 +#define PR_BITS_PER_BYTE    8
95 +#define PR_BITS_PER_SHORT   16
96 +#define PR_BITS_PER_INT     32
97 +#define PR_BITS_PER_INT64   64
98 +#define PR_BITS_PER_LONG    64
99 +#define PR_BITS_PER_FLOAT   32
100 +#define PR_BITS_PER_DOUBLE  64
101 +#define PR_BITS_PER_WORD    64
102 +
103 +#define PR_BITS_PER_BYTE_LOG2   3
104 +#define PR_BITS_PER_SHORT_LOG2  4
105 +#define PR_BITS_PER_INT_LOG2    5
106 +#define PR_BITS_PER_INT64_LOG2  6
107 +#define PR_BITS_PER_LONG_LOG2   6
108 +#define PR_BITS_PER_FLOAT_LOG2  5
109 +#define PR_BITS_PER_DOUBLE_LOG2 6
110 +#define PR_BITS_PER_WORD_LOG2   6
111 +
112 +#define PR_ALIGN_OF_SHORT   2
113 +#define PR_ALIGN_OF_INT     4
114 +#define PR_ALIGN_OF_LONG    8
115 +#define PR_ALIGN_OF_INT64   8
116 +#define PR_ALIGN_OF_FLOAT   4
117 +#define PR_ALIGN_OF_DOUBLE  8
118 +#define PR_ALIGN_OF_POINTER 8
119 +#define PR_ALIGN_OF_WORD    8
120 +
121 +#define PR_BYTES_PER_WORD_LOG2  3
122 +#define PR_BYTES_PER_DWORD_LOG2 3
123 +
124  #elif defined(__mc68000__)
125  
126  #undef  IS_LITTLE_ENDIAN
127 diff -durN mozilla.orig/nsprpub/pr/include/md/_linux.h mozilla/nsprpub/pr/include/md/_linux.h
128 --- mozilla.orig/nsprpub/pr/include/md/_linux.h 2003-02-27 00:53:39.000000000 +0100
129 +++ mozilla/nsprpub/pr/include/md/_linux.h      2005-01-01 01:18:35.323556376 +0100
130 @@ -49,6 +49,8 @@
131  #define _PR_SI_ARCHITECTURE "alpha"
132  #elif defined(__ia64__)
133  #define _PR_SI_ARCHITECTURE "ia64"
134 +#elif defined(__x86_64__)
135 +#define _PR_SI_ARCHITECTURE "x86-64"
136  #elif defined(__mc68000__)
137  #define _PR_SI_ARCHITECTURE "m68k"
138  #elif defined(__sparc__)
139 @@ -107,6 +109,19 @@
140  #define _MD_ATOMIC_SET                _PR_ia64_AtomicSet
141  #endif
142  
143 +#if defined(__x86_64__)
144 +#define _PR_HAVE_ATOMIC_OPS
145 +#define _MD_INIT_ATOMIC()
146 +extern PRInt32 _PR_x86_64_AtomicIncrement(PRInt32 *val);
147 +#define _MD_ATOMIC_INCREMENT          _PR_x86_64_AtomicIncrement
148 +extern PRInt32 _PR_x86_64_AtomicDecrement(PRInt32 *val);
149 +#define _MD_ATOMIC_DECREMENT          _PR_x86_64_AtomicDecrement
150 +extern PRInt32 _PR_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
151 +#define _MD_ATOMIC_ADD                _PR_x86_64_AtomicAdd
152 +extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
153 +#define _MD_ATOMIC_SET                _PR_x86_64_AtomicSet
154 +#endif
155 +
156  #define USE_SETJMP
157  #if defined(__GLIBC__) && __GLIBC__ >= 2
158  #define _PR_POLL_AVAILABLE
159 diff -durN mozilla.orig/nsprpub/pr/src/io/prprf.c mozilla/nsprpub/pr/src/io/prprf.c
160 --- mozilla.orig/nsprpub/pr/src/io/prprf.c      2003-02-27 00:53:42.000000000 +0100
161 +++ mozilla/nsprpub/pr/src/io/prprf.c   2005-01-01 01:18:35.324556224 +0100
162 @@ -51,7 +51,10 @@
163  ** Note: on some platforms va_list is defined as an array,
164  ** and requires array notation.
165  */
166 -#if (defined(LINUX) && defined(__powerpc__)) || \
167 +#if (defined(LINUX) && defined(__x86_64__))
168 +#include <stdarg.h>
169 +#define VARARGS_ASSIGN(foo, bar) __va_copy((foo), (bar))
170 +#elif (defined(LINUX) && defined(__powerpc__)) || \
171      (defined(LINUX) && defined(__s390__)) || \
172      (defined(LINUX) && defined(__s390x__)) || \
173      defined(WIN16) || defined(QNX) || \
174 diff -durN mozilla.orig/nsprpub/pr/src/md/unix/os_Linux_x86_64.s mozilla/nsprpub/pr/src/md/unix/os_Linux_x86_64.s
175 --- mozilla.orig/nsprpub/pr/src/md/unix/os_Linux_x86_64.s       1970-01-01 01:00:00.000000000 +0100
176 +++ mozilla/nsprpub/pr/src/md/unix/os_Linux_x86_64.s    2005-01-01 01:18:35.325556072 +0100
177 @@ -0,0 +1,91 @@
178 +/ -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
179 +/ 
180 +/ The contents of this file are subject to the Mozilla Public
181 +/ License Version 1.1 (the "License"); you may not use this file
182 +/ except in compliance with the License. You may obtain a copy of
183 +/ the License at http://www.mozilla.org/MPL/
184 +/ 
185 +/ Software distributed under the License is distributed on an "AS
186 +/ IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
187 +/ implied. See the License for the specific language governing
188 +/ rights and limitations under the License.
189 +/ 
190 +/ The Original Code is the Netscape Portable Runtime (NSPR).
191 +/ 
192 +/ The Initial Developer of the Original Code is Netscape
193 +/ Communications Corporation.  Portions created by Netscape are 
194 +/ Copyright (C) 2000 Netscape Communications Corporation.  All
195 +/ Rights Reserved.
196 +/ 
197 +/ Contributor(s):
198 +/ 
199 +/ Alternatively, the contents of this file may be used under the
200 +/ terms of the GNU General Public License Version 2 or later (the
201 +/ "GPL"), in which case the provisions of the GPL are applicable 
202 +/ instead of those above.  If you wish to allow use of your 
203 +/ version of this file only under the terms of the GPL and not to
204 +/ allow others to use your version of this file under the MPL,
205 +/ indicate your decision by deleting the provisions above and
206 +/ replace them with the notice and other provisions required by
207 +/ the GPL.  If you do not delete the provisions above, a recipient
208 +/ may use your version of this file under either the MPL or the
209 +/ GPL.
210 +/ 
211 +
212 +/ PRInt32 _PR_x86_64_AtomicIncrement(PRInt32 *val)
213 +/
214 +/ Atomically increment the integer pointed to by 'val' and return
215 +/ the result of the increment.
216 +/
217 +    .text
218 +    .globl _PR_x86_64_AtomicIncrement
219 +    .align 4
220 +_PR_x86_64_AtomicIncrement:
221 +    movl $1, %eax
222 +    lock
223 +    xaddl %eax, (%rdi)
224 +    incl %eax
225 +    ret
226 +
227 +/ PRInt32 _PR_x86_64_AtomicDecrement(PRInt32 *val)
228 +/
229 +/ Atomically decrement the integer pointed to by 'val' and return
230 +/ the result of the decrement.
231 +/
232 +    .text
233 +    .globl _PR_x86_64_AtomicDecrement
234 +    .align 4
235 +_PR_x86_64_AtomicDecrement:
236 +    movl $-1, %eax
237 +    lock
238 +    xaddl %eax, (%rdi)
239 +    decl %eax
240 +    ret
241 +
242 +/ PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval)
243 +/
244 +/ Atomically set the integer pointed to by 'val' to the new
245 +/ value 'newval' and return the old value.
246 +    .text
247 +    .globl _PR_x86_64_AtomicSet
248 +    .align 4
249 +_PR_x86_64_AtomicSet:
250 +    movl %esi, %eax
251 +    lock
252 +    xchgl %eax, (%rdi)
253 +    ret
254 +
255 +/ PRInt32 _PR_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val)
256 +/
257 +/ Atomically add 'val' to the integer pointed to by 'ptr'
258 +/ and return the result of the addition.
259 +/
260 +    .text
261 +    .globl _PR_x86_64_AtomicAdd
262 +    .align 4
263 +_PR_x86_64_AtomicAdd:
264 +    movl %esi, %eax
265 +    lock
266 +    xaddl %eax, (%rdi)
267 +    addl %esi, %eax
268 +    ret
269 diff -durN mozilla.orig/security/coreconf/Linux.mk mozilla/security/coreconf/Linux.mk
270 --- mozilla.orig/security/coreconf/Linux.mk     2003-05-01 02:31:20.000000000 +0200
271 +++ mozilla/security/coreconf/Linux.mk  2005-01-01 01:18:35.344553184 +0100
272 @@ -66,6 +66,10 @@
273         OS_REL_CFLAGS   = -DLINUX1_2 -D_XOPEN_SOURCE
274         CPU_ARCH        = ia64
275  else
276 +ifeq ($(OS_TEST),x86_64)
277 +       OS_REL_CFLAGS   = -DLINUX1_2 -D_XOPEN_SOURCE
278 +       CPU_ARCH        = x86_64
279 +else
280  ifeq ($(OS_TEST),sparc)
281         OS_REL_CFLAGS   = -DLINUX1_2 -D_XOPEN_SOURCE
282         CPU_ARCH        = sparc
283 @@ -107,6 +111,7 @@
284  endif
285  endif
286  endif
287 +endif
288  
289  
290  LIBC_TAG               = _glibc
291 diff -durN mozilla.orig/xpcom/reflect/xptcall/src/md/unix/Makefile.in mozilla/xpcom/reflect/xptcall/src/md/unix/Makefile.in
292 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/Makefile.in  2003-08-15 06:00:23.000000000 +0200
293 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/Makefile.in       2005-01-01 01:18:35.345553032 +0100
294 @@ -55,10 +55,15 @@
295  # Migrate other platforms here after testing
296  #
297  ifneq (,$(filter Linux,$(OS_ARCH)))
298 +# Linux/x86-64
299 +ifeq (x86_64,$(OS_TEST))
300 +CPPSRCS                := xptcinvoke_x86_64_linux.cpp xptcstubs_x86_64_linux.cpp
301 +else
302  ifeq (86,$(findstring 86,$(OS_TEST)))
303  CPPSRCS                := xptcinvoke_gcc_x86_unix.cpp xptcstubs_gcc_x86_unix.cpp
304  endif
305  endif
306 +endif
307  # IA64 Linux
308  ifneq (,$(filter Linux,$(OS_ARCH)))
309  ifneq (,$(findstring ia64,$(OS_TEST)))
310 diff -durN mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_linux.cpp mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_linux.cpp
311 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_linux.cpp  1970-01-01 01:00:00.000000000 +0100
312 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_linux.cpp       2005-01-01 01:18:35.346552880 +0100
313 @@ -0,0 +1,174 @@
314 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
315 +// Platform specific code to invoke XPCOM methods on native objects
316 +
317 +#include "xptcprivate.h"
318 +
319 +// 6 integral parameters are passed in registers
320 +const PRUint32 GPR_COUNT = 6;
321 +
322 +// 8 floating point parameters are passed in SSE registers
323 +const PRUint32 FPR_COUNT = 8;
324 +
325 +// Remember that these 'words' are 64-bit long
326 +static inline void
327 +invoke_count_words(PRUint32 paramCount, nsXPTCVariant * s,
328 +                   PRUint32 & nr_gpr, PRUint32 & nr_fpr, PRUint32 & nr_stack)
329 +{
330 +    nr_gpr = 1; // skip one GP register for 'that'
331 +    nr_fpr = 0;
332 +    nr_stack = 0;
333 +
334 +    /* Compute number of eightbytes of class MEMORY.  */
335 +    for (uint32 i = 0; i < paramCount; i++, s++) {
336 +        if (!s->IsPtrData()
337 +            && (s->type == nsXPTType::T_FLOAT || s->type == nsXPTType::T_DOUBLE)) {
338 +            if (nr_fpr < FPR_COUNT)
339 +                nr_fpr++;
340 +            else
341 +                nr_stack++;
342 +        }
343 +        else {
344 +            if (nr_gpr < GPR_COUNT)
345 +                nr_gpr++;
346 +            else
347 +                nr_stack++;
348 +        }
349 +    }
350 +}
351 +
352 +static void
353 +invoke_copy_to_stack(PRUint64 * d, PRUint32 paramCount, nsXPTCVariant * s,
354 +                     PRUint64 * gpregs, double * fpregs)
355 +{
356 +    PRUint32 nr_gpr = 1; // skip one GP register for 'that'
357 +    PRUint32 nr_fpr = 0;
358 +    PRUint64 value;
359 +
360 +    for (uint32 i = 0; i < paramCount; i++, s++) {
361 +        if (s->IsPtrData())
362 +            value = (PRUint64) s->ptr;
363 +        else {
364 +            switch (s->type) {
365 +            case nsXPTType::T_FLOAT:                                break;
366 +            case nsXPTType::T_DOUBLE:                               break;
367 +            case nsXPTType::T_I8:     value = s->val.i8;            break;
368 +            case nsXPTType::T_I16:    value = s->val.i16;           break;
369 +            case nsXPTType::T_I32:    value = s->val.i32;           break;
370 +            case nsXPTType::T_I64:    value = s->val.i64;           break;
371 +            case nsXPTType::T_U8:     value = s->val.u8;            break;
372 +            case nsXPTType::T_U16:    value = s->val.u16;           break;
373 +            case nsXPTType::T_U32:    value = s->val.u32;           break;
374 +            case nsXPTType::T_U64:    value = s->val.u64;           break;
375 +            case nsXPTType::T_BOOL:   value = s->val.b;             break;
376 +            case nsXPTType::T_CHAR:   value = s->val.c;             break;
377 +            case nsXPTType::T_WCHAR:  value = s->val.wc;            break;
378 +            default:                  value = (PRUint64) s->val.p;  break;
379 +            }
380 +        }
381 +
382 +        if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
383 +            if (nr_fpr < FPR_COUNT)
384 +                fpregs[nr_fpr++] = s->val.d;
385 +            else {
386 +                *((double *)d) = s->val.d;
387 +                d++;
388 +            }
389 +        }
390 +        else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
391 +            if (nr_fpr < FPR_COUNT)
392 +                // The value in %xmm register is already prepared to
393 +                // be retrieved as a float. Therefore, we pass the
394 +                // value verbatim, as a double without conversion.
395 +                fpregs[nr_fpr++] = s->val.d;
396 +            else {
397 +                *((float *)d) = s->val.f;
398 +                d++;
399 +            }
400 +        }
401 +        else {
402 +            if (nr_gpr < GPR_COUNT)
403 +                gpregs[nr_gpr++] = value;
404 +            else
405 +                *d++ = value;
406 +        }
407 +    }
408 +}
409 +
410 +extern "C"
411 +XPTC_PUBLIC_API(nsresult)
412 +XPTC_InvokeByIndex(nsISupports * that, PRUint32 methodIndex,
413 +                   PRUint32 paramCount, nsXPTCVariant * params)
414 +{
415 +    PRUint32 nr_gpr, nr_fpr, nr_stack;
416 +    invoke_count_words(paramCount, params, nr_gpr, nr_fpr, nr_stack);
417 +    
418 +    // Stack, if used, must be 16-bytes aligned
419 +    if (nr_stack)
420 +        nr_stack = (nr_stack + 1) & ~1;
421 +
422 +    // Load parameters to stack, if necessary
423 +    PRUint64 *stack = (PRUint64 *) __builtin_alloca(nr_stack * 8);
424 +    PRUint64 gpregs[GPR_COUNT];
425 +    double fpregs[FPR_COUNT];
426 +    invoke_copy_to_stack(stack, paramCount, params, gpregs, fpregs);
427 +
428 +    // Load FPR registers from fpregs[]
429 +    register double d0 asm("xmm0");
430 +    register double d1 asm("xmm1");
431 +    register double d2 asm("xmm2");
432 +    register double d3 asm("xmm3");
433 +    register double d4 asm("xmm4");
434 +    register double d5 asm("xmm5");
435 +    register double d6 asm("xmm6");
436 +    register double d7 asm("xmm7");
437 +
438 +    switch (nr_fpr) {
439 +#define ARG_FPR(N) \
440 +    case N+1: d##N = fpregs[N];
441 +        ARG_FPR(7);
442 +        ARG_FPR(6);
443 +        ARG_FPR(5);
444 +        ARG_FPR(4);
445 +        ARG_FPR(3);
446 +        ARG_FPR(2);
447 +        ARG_FPR(1);
448 +        ARG_FPR(0);
449 +    case 0:;
450 +#undef ARG_FPR
451 +    }
452 +    
453 +    // Load GPR registers from gpregs[]
454 +    register PRUint64 a0 asm("rdi");
455 +    register PRUint64 a1 asm("rsi");
456 +    register PRUint64 a2 asm("rdx");
457 +    register PRUint64 a3 asm("rcx");
458 +    register PRUint64 a4 asm("r8");
459 +    register PRUint64 a5 asm("r9");
460 +    
461 +    switch (nr_gpr) {
462 +#define ARG_GPR(N) \
463 +    case N+1: a##N = gpregs[N];
464 +        ARG_GPR(5);
465 +        ARG_GPR(4);
466 +        ARG_GPR(3);
467 +        ARG_GPR(2);
468 +        ARG_GPR(1);
469 +    case 1: a0 = (PRUint64) that;
470 +    case 0:;
471 +#undef ARG_GPR
472 +    }
473 +
474 +    // Ensure that assignments to SSE registers won't be optimized away
475 +    asm("" ::
476 +        "x" (d0), "x" (d1), "x" (d2), "x" (d3),
477 +        "x" (d4), "x" (d5), "x" (d6), "x" (d7));
478 +    
479 +    // Get pointer to method
480 +    PRUint64 methodAddress = *((PRUint64 *)that);
481 +    methodAddress += 8 * methodIndex;
482 +    methodAddress = *((PRUint64 *)methodAddress);
483 +    
484 +    typedef PRUint32 (*Method)(PRUint64, PRUint64, PRUint64, PRUint64, PRUint64, PRUint64);
485 +    PRUint32 result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5);
486 +    return result;
487 +}
488 diff -durN mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp mozilla/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp
489 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp   1970-01-01 01:00:00.000000000 +0100
490 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp        2005-01-01 01:18:35.347552728 +0100
491 @@ -0,0 +1,206 @@
492 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
493 +
494 +// Implement shared vtbl methods.
495 +
496 +#include "xptcprivate.h"
497 +
498 +// The Linux/x86-64 ABI passes the first 6 integral parameters and the
499 +// first 8 floating point parameters in registers (rdi, rsi, rdx, rcx,
500 +// r8, r9 and xmm0-xmm7), no stack space is allocated for these by the
501 +// caller.  The rest of the parameters are passed in the callers stack
502 +// area.
503 +
504 +const PRUint32 PARAM_BUFFER_COUNT   = 16;
505 +const PRUint32 GPR_COUNT            = 6;
506 +const PRUint32 FPR_COUNT            = 8;
507 +
508 +// PrepareAndDispatch() is called by SharedStub() and calls the actual method.
509 +//
510 +// - 'args[]' contains the arguments passed on stack
511 +// - 'gpregs[]' contains the arguments passed in integer registers
512 +// - 'fpregs[]' contains the arguments passed in floating point registers
513 +// 
514 +// The parameters are mapped into an array of type 'nsXPTCMiniVariant'
515 +// and then the method gets called.
516 +
517 +extern "C" nsresult
518 +PrepareAndDispatch(nsXPTCStubBase * self, PRUint32 methodIndex,
519 +                   PRUint64 * args, PRUint64 * gpregs, double *fpregs)
520 +{
521 +    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
522 +    nsXPTCMiniVariant* dispatchParams = NULL;
523 +    nsIInterfaceInfo* iface_info = NULL;
524 +    const nsXPTMethodInfo* info;
525 +    PRUint32 paramCount;
526 +    PRUint32 i;
527 +    nsresult result = NS_ERROR_FAILURE;
528 +
529 +    NS_ASSERTION(self,"no self");
530 +
531 +    self->GetInterfaceInfo(&iface_info);
532 +    NS_ASSERTION(iface_info,"no interface info");
533 +    if (! iface_info)
534 +        return NS_ERROR_UNEXPECTED;
535 +
536 +    iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
537 +    NS_ASSERTION(info,"no method info");
538 +    if (! info)
539 +        return NS_ERROR_UNEXPECTED;
540 +
541 +    paramCount = info->GetParamCount();
542 +
543 +    // setup variant array pointer
544 +    if(paramCount > PARAM_BUFFER_COUNT)
545 +        dispatchParams = new nsXPTCMiniVariant[paramCount];
546 +    else
547 +        dispatchParams = paramBuffer;
548 +
549 +    NS_ASSERTION(dispatchParams,"no place for params");
550 +    if (! dispatchParams)
551 +        return NS_ERROR_OUT_OF_MEMORY;
552 +
553 +    PRUint64* ap = args;
554 +    PRUint32 nr_gpr = 1;    // skip one GPR register for 'that'
555 +    PRUint32 nr_fpr = 0;
556 +    PRUint64 value;
557 +
558 +    for(i = 0; i < paramCount; i++) {
559 +        const nsXPTParamInfo& param = info->GetParam(i);
560 +        const nsXPTType& type = param.GetType();
561 +        nsXPTCMiniVariant* dp = &dispatchParams[i];
562 +       
563 +        if (!param.IsOut() && type == nsXPTType::T_DOUBLE) {
564 +            if (nr_fpr < FPR_COUNT)
565 +                dp->val.d = fpregs[nr_fpr++];
566 +            else
567 +                dp->val.d = *(double*) ap++;
568 +            continue;
569 +        }
570 +        else if (!param.IsOut() && type == nsXPTType::T_FLOAT) {
571 +            if (nr_fpr < FPR_COUNT)
572 +                // The value in %xmm register is already prepared to
573 +                // be retrieved as a float. Therefore, we pass the
574 +                // value verbatim, as a double without conversion.
575 +                dp->val.d = *(double*) ap++;
576 +            else
577 +                dp->val.f = *(float*) ap++;
578 +            continue;
579 +        }
580 +        else {
581 +            if (nr_gpr < GPR_COUNT)
582 +                value = gpregs[nr_gpr++];
583 +            else
584 +                value = *ap++;
585 +        }
586 +
587 +        if (param.IsOut() || !type.IsArithmetic()) {
588 +            dp->val.p = (void*) value;
589 +            continue;
590 +        }
591 +
592 +        switch (type) {
593 +        case nsXPTType::T_I8:      dp->val.i8  = (PRInt8)   value; break;
594 +        case nsXPTType::T_I16:     dp->val.i16 = (PRInt16)  value; break;
595 +        case nsXPTType::T_I32:     dp->val.i32 = (PRInt32)  value; break;
596 +        case nsXPTType::T_I64:     dp->val.i64 = (PRInt64)  value; break;
597 +        case nsXPTType::T_U8:      dp->val.u8  = (PRUint8)  value; break;
598 +        case nsXPTType::T_U16:     dp->val.u16 = (PRUint16) value; break;
599 +        case nsXPTType::T_U32:     dp->val.u32 = (PRUint32) value; break;
600 +        case nsXPTType::T_U64:     dp->val.u64 = (PRUint64) value; break;
601 +        case nsXPTType::T_BOOL:    dp->val.b   = (PRBool)   value; break;
602 +        case nsXPTType::T_CHAR:    dp->val.c   = (char)     value; break;
603 +        case nsXPTType::T_WCHAR:   dp->val.wc  = (wchar_t)  value; break;
604 +
605 +        default:
606 +            NS_ASSERTION(0, "bad type");
607 +            break;
608 +        }
609 +    }
610 +
611 +    result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
612 +
613 +    NS_RELEASE(iface_info);
614 +
615 +    if (dispatchParams != paramBuffer)
616 +        delete [] dispatchParams;
617 +
618 +    return result;
619 +}
620 +
621 +#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
622 +// Linux/x86-64 uses gcc >= 3.1
623 +#define STUB_ENTRY(n) \
624 +asm(".section  \".text\"\n\t" \
625 +    ".align    2\n\t" \
626 +    ".if       " #n " < 10\n\t" \
627 +    ".globl    _ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
628 +    ".type     _ZN14nsXPTCStubBase5Stub" #n "Ev,@function\n" \
629 +    "_ZN14nsXPTCStubBase5Stub" #n "Ev:\n\t" \
630 +    ".elseif   " #n " < 100\n\t" \
631 +    ".globl    _ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
632 +    ".type     _ZN14nsXPTCStubBase6Stub" #n "Ev,@function\n" \
633 +    "_ZN14nsXPTCStubBase6Stub" #n "Ev:\n\t" \
634 +    ".elseif    " #n " < 1000\n\t" \
635 +    ".globl     _ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
636 +    ".type      _ZN14nsXPTCStubBase7Stub" #n "Ev,@function\n" \
637 +    "_ZN14nsXPTCStubBase7Stub" #n "Ev:\n\t" \
638 +    ".else\n\t" \
639 +    ".err      \"stub number " #n " >= 1000 not yet supported\"\n\t" \
640 +    ".endif\n\t" \
641 +    "movl      $" #n ", %eax\n\t" \
642 +    "jmp       SharedStub\n\t" \
643 +    ".if       " #n " < 10\n\t" \
644 +    ".size     _ZN14nsXPTCStubBase5Stub" #n "Ev,.-_ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
645 +    ".elseif   " #n " < 100\n\t" \
646 +    ".size     _ZN14nsXPTCStubBase6Stub" #n "Ev,.-_ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
647 +    ".else\n\t" \
648 +    ".size     _ZN14nsXPTCStubBase7Stub" #n "Ev,.-_ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
649 +    ".endif");
650 +
651 +// static nsresult SharedStub(PRUint32 methodIndex)
652 +asm(".section   \".text\"\n\t"
653 +    ".align     2\n\t"
654 +    ".type      SharedStub,@function\n\t"
655 +    "SharedStub:\n\t"
656 +    // make room for gpregs (48), fpregs (64)
657 +    "pushq      %rbp\n\t"
658 +    "movq       %rsp,%rbp\n\t"
659 +    "subq       $112,%rsp\n\t"
660 +    // save GP registers
661 +    "movq       %rdi,-112(%rbp)\n\t"
662 +    "movq       %rsi,-104(%rbp)\n\t"
663 +    "movq       %rdx, -96(%rbp)\n\t"
664 +    "movq       %rcx, -88(%rbp)\n\t"
665 +    "movq       %r8 , -80(%rbp)\n\t"
666 +    "movq       %r9 , -72(%rbp)\n\t"
667 +    "leaq       -112(%rbp),%rcx\n\t"
668 +    // save FP registers
669 +    "movsd      %xmm0,-64(%rbp)\n\t"
670 +    "movsd      %xmm1,-56(%rbp)\n\t"
671 +    "movsd      %xmm2,-48(%rbp)\n\t"
672 +    "movsd      %xmm3,-40(%rbp)\n\t"
673 +    "movsd      %xmm4,-32(%rbp)\n\t"
674 +    "movsd      %xmm5,-24(%rbp)\n\t"
675 +    "movsd      %xmm6,-16(%rbp)\n\t"
676 +    "movsd      %xmm7, -8(%rbp)\n\t"
677 +    "leaq       -64(%rbp),%r8\n\t"
678 +    // rdi has the 'self' pointer already
679 +    "movl       %eax,%esi\n\t"
680 +    "leaq       16(%rbp),%rdx\n\t"
681 +    "call       PrepareAndDispatch@plt\n\t"
682 +    "leave\n\t"
683 +    "ret\n\t"
684 +    ".size      SharedStub,.-SharedStub");
685 +
686 +#define SENTINEL_ENTRY(n) \
687 +nsresult nsXPTCStubBase::Sentinel##n() \
688 +{ \
689 +    NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
690 +    return NS_ERROR_NOT_IMPLEMENTED; \
691 +}
692 +
693 +#include "xptcstubsdef.inc"
694 +
695 +#else
696 +#error "can't find a compiler to use"
697 +#endif /* __GNUC__ */
This page took 0.093651 seconds and 3 git commands to generate.