]> gitweb @ CieloNegro.org - pkgsrc-firefox3.git/blob - files/xptcinvoke_sparc64_netbsd.cpp
Initial revision of the upstream www/firefox3
[pkgsrc-firefox3.git] / files / xptcinvoke_sparc64_netbsd.cpp
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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) 1998 Netscape Communications Corporation. All
18  * Rights Reserved.
19  *
20  * Contributor(s): 
21  */
22
23 /* Platform specific code to invoke XPCOM methods on native objects */
24
25 #include "xptcprivate.h"
26
27 #if !defined(__sparc64__) && !defined(_LP64)
28 #error "This code is for Sparc64 only"
29 #endif
30
31 extern "C" PRUint32
32 invoke_copy_to_stack(PRUint64* d, PRUint32 paramCount, nsXPTCVariant* s)
33 {
34   /*
35     We need to copy the parameters for this function to locals and use them
36     from there since the parameters occupy the same stack space as the stack
37     we're trying to populate.
38   */
39   PRUint64 *l_d = d;
40   nsXPTCVariant *l_s = s;
41   PRUint64 l_paramCount = paramCount;
42   PRUint64 regCount = 0;  // return the number of registers to load from the stack
43
44   for(PRUint64 i = 0; i < l_paramCount; i++, l_d++, l_s++)
45   {
46     if (regCount < 5) regCount++;
47
48     if (l_s->IsPtrData())
49     {
50       *l_d = (PRUint64)l_s->ptr;
51       continue;
52     }
53     switch (l_s->type)
54     {
55       case nsXPTType::T_I8    : *((PRInt64*)l_d)     = l_s->val.i8;    break;
56       case nsXPTType::T_I16   : *((PRInt64*)l_d)     = l_s->val.i16;   break;
57       case nsXPTType::T_I32   : *((PRInt64*)l_d)     = l_s->val.i32;   break;
58       case nsXPTType::T_I64   : *((PRInt64*)l_d)     = l_s->val.i64;   break;
59       
60       case nsXPTType::T_U8    : *((PRUint64*)l_d)    = l_s->val.u8;    break;
61       case nsXPTType::T_U16   : *((PRUint64*)l_d)    = l_s->val.u16;   break;
62       case nsXPTType::T_U32   : *((PRUint64*)l_d)    = l_s->val.u32;   break;
63       case nsXPTType::T_U64   : *((PRUint64*)l_d)    = l_s->val.u64;   break;
64
65       /* in the case of floats, we want to put the bits in to the
66          64bit space right justified... floats in the paramter array on
67          sparcv9 use odd numbered registers.. %f1, %f3, so we have to skip
68          the space that would be occupied by %f0, %f2, etc.
69       */
70       case nsXPTType::T_FLOAT : *(((float*)l_d) + 1) = l_s->val.f;     break;
71       case nsXPTType::T_DOUBLE: *((double*)l_d)      = l_s->val.d;     break;
72       case nsXPTType::T_BOOL  : *((PRInt64*)l_d)      = l_s->val.b;     break;
73       case nsXPTType::T_CHAR  : *((PRUint64*)l_d)    = l_s->val.c;     break;
74       case nsXPTType::T_WCHAR : *((PRInt64*)l_d)     = l_s->val.wc;    break;
75
76       default:
77         // all the others are plain pointer types
78         *((void**)l_d) = l_s->val.p;
79         break;
80     }
81   }
82   
83   return regCount;
84 }