~ubuntu-branches/ubuntu/trusty/virtualbox-lts-xenial/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_netbsd.cpp

  • Committer: Package Import Robot
  • Author(s): Gianfranco Costamagna
  • Date: 2016-02-23 14:28:26 UTC
  • Revision ID: package-import@ubuntu.com-20160223142826-bdu69el2z6wa2a44
Tags: upstream-4.3.36-dfsg
ImportĀ upstreamĀ versionĀ 4.3.36-dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
2
/* ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Mozilla Public License Version
 
6
 * 1.1 (the "License"); you may not use this file except in compliance with
 
7
 * the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/MPL/
 
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
 *
 
27
 * Alternatively, the contents of this file may be used under the terms of
 
28
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 
29
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
30
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
31
 * of those above. If you wish to allow use of your version of this file only
 
32
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
33
 * use your version of this file under the terms of the MPL, indicate your
 
34
 * decision by deleting the provisions above and replace them with the notice
 
35
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
36
 * the provisions above, a recipient may use your version of this file under
 
37
 * the terms of any one of the MPL, the GPL or the LGPL.
 
38
 *
 
39
 * ***** END LICENSE BLOCK ***** */
 
40
 
 
41
// Platform specific code to invoke XPCOM methods on native objects
 
42
 
 
43
// The purpose of XPTC_InvokeByIndex() is to map a platform
 
44
// indepenpent call to the platform ABI. To do that,
 
45
// XPTC_InvokeByIndex() has to determine the method to call via vtable
 
46
// access. The parameters for the method are read from the
 
47
// nsXPTCVariant* and prepared for th native ABI.  For the Linux/PPC
 
48
// ABI this means that the first 8 integral and floating point
 
49
// parameters are passed in registers.
 
50
 
 
51
#include "xptcprivate.h"
 
52
 
 
53
// 8 integral parameters are passed in registers
 
54
#define GPR_COUNT     8
 
55
 
 
56
// 8 floating point parameters are passed in registers, floats are
 
57
// promoted to doubles when passed in registers
 
58
#define FPR_COUNT     8
 
59
 
 
60
extern "C" PRUint32
 
61
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
 
62
{
 
63
  return PRUint32(((paramCount * 2) + 3) & ~3);
 
64
}
 
65
 
 
66
extern "C" void
 
67
invoke_copy_to_stack(PRUint32* d,
 
68
                     PRUint32 paramCount,
 
69
                     nsXPTCVariant* s, 
 
70
                     PRUint32* gpregs,
 
71
                     double* fpregs)
 
72
{
 
73
    PRUint32 gpr = 1; // skip one GP reg for 'that'
 
74
    PRUint32 fpr = 0;
 
75
    PRUint32 tempu32;
 
76
    PRUint64 tempu64;
 
77
    
 
78
    for(uint32 i = 0; i < paramCount; i++, s++) {
 
79
        if(s->IsPtrData())
 
80
            tempu32 = (PRUint32) s->ptr;
 
81
        else {
 
82
            switch(s->type) {
 
83
            case nsXPTType::T_FLOAT:                                  break;
 
84
            case nsXPTType::T_DOUBLE:                                 break;
 
85
            case nsXPTType::T_I8:     tempu32 = s->val.i8;            break;
 
86
            case nsXPTType::T_I16:    tempu32 = s->val.i16;           break;
 
87
            case nsXPTType::T_I32:    tempu32 = s->val.i32;           break;
 
88
            case nsXPTType::T_I64:    tempu64 = s->val.i64;           break;
 
89
            case nsXPTType::T_U8:     tempu32 = s->val.u8;            break;
 
90
            case nsXPTType::T_U16:    tempu32 = s->val.u16;           break;
 
91
            case nsXPTType::T_U32:    tempu32 = s->val.u32;           break;
 
92
            case nsXPTType::T_U64:    tempu64 = s->val.u64;           break;
 
93
            case nsXPTType::T_BOOL:   tempu32 = s->val.b;             break;
 
94
            case nsXPTType::T_CHAR:   tempu32 = s->val.c;             break;
 
95
            case nsXPTType::T_WCHAR:  tempu32 = s->val.wc;            break;
 
96
            default:                  tempu32 = (PRUint32) s->val.p;  break;
 
97
            }
 
98
        }
 
99
 
 
100
        if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
 
101
            if (fpr < FPR_COUNT)
 
102
                fpregs[fpr++]    = s->val.d;
 
103
            else {
 
104
                if ((PRUint32) d & 4) d++; // doubles are 8-byte aligned on stack
 
105
                *((double*) d) = s->val.d;
 
106
                d += 2;
 
107
                if (gpr < GPR_COUNT)
 
108
                    gpr += 2;
 
109
            }
 
110
        }
 
111
        else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
 
112
            if (fpr < FPR_COUNT)
 
113
                fpregs[fpr++]   = s->val.f; // if passed in registers, floats are promoted to doubles
 
114
            else {
 
115
                *((float*) d) = s->val.f;
 
116
                d += 1;
 
117
                if (gpr < GPR_COUNT)
 
118
                    gpr += 1;
 
119
            }
 
120
        }
 
121
        else if (!s->IsPtrData() && (s->type == nsXPTType::T_I64
 
122
                                     || s->type == nsXPTType::T_U64)) {
 
123
            if ((gpr + 1) < GPR_COUNT) {
 
124
                if (gpr & 1) gpr++; // longlongs are aligned in odd/even register pairs, eg. r5/r6
 
125
                *((PRUint64*) &gpregs[gpr]) = tempu64;
 
126
                gpr += 2;
 
127
            }
 
128
            else {
 
129
                if ((PRUint32) d & 4) d++; // longlongs are 8-byte aligned on stack
 
130
                *((PRUint64*) d)            = tempu64;
 
131
                d += 2;
 
132
            }
 
133
        }
 
134
        else {
 
135
            if (gpr < GPR_COUNT)
 
136
                gpregs[gpr++] = tempu32;
 
137
            else
 
138
                *d++          = tempu32;
 
139
        }
 
140
        
 
141
    }
 
142
}
 
143
 
 
144
extern "C"
 
145
XPTC_PUBLIC_API(nsresult)
 
146
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
 
147
                   PRUint32 paramCount, nsXPTCVariant* params);