1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 /* Platform specific code to invoke XPCOM methods on native objects */
6 
7 #include "xptcprivate.h"
8 
9 #ifdef _AIX
10 
11 extern "C" void
invoke_copy_to_stack(uint64_t * d,uint32_t paramCount,nsXPTCVariant * s,double * fprData)12 invoke_copy_to_stack(uint64_t* d, uint32_t paramCount, nsXPTCVariant* s, double *fprData)
13 {
14 /*
15     We need to copy the parameters for this function to locals and use them
16     from there since the parameters occupy the same stack space as the stack
17     we're trying to populate.
18 */
19     uint64_t *l_d = d;
20     nsXPTCVariant *l_s = s;
21     uint32_t l_paramCount = paramCount, fpCount = 0;
22     double *l_fprData = fprData;
23 
24     for(uint32_t i = 0; i < l_paramCount; i++, l_d++, l_s++)
25     {
26         if(l_s->IsPtrData())
27         {
28             *l_d = (uint64_t)l_s->ptr;
29             continue;
30         }
31         switch(l_s->type)
32         {
33         case nsXPTType::T_I8:    *l_d = (uint64_t)l_s->val.i8;   break;
34         case nsXPTType::T_I16:   *l_d = (uint64_t)l_s->val.i16;  break;
35         case nsXPTType::T_I32:   *l_d = (uint64_t)l_s->val.i32;  break;
36         case nsXPTType::T_I64:   *l_d = (uint64_t)l_s->val.i64;  break;
37         case nsXPTType::T_U8:    *l_d = (uint64_t)l_s->val.u8;   break;
38         case nsXPTType::T_U16:   *l_d = (uint64_t)l_s->val.u16;  break;
39         case nsXPTType::T_U32:   *l_d = (uint64_t)l_s->val.u32;  break;
40         case nsXPTType::T_U64:   *l_d = (uint64_t)l_s->val.u64;  break;
41         case nsXPTType::T_BOOL:  *l_d = (uint64_t)l_s->val.b;    break;
42         case nsXPTType::T_CHAR:  *l_d = (uint64_t)l_s->val.c;    break;
43         case nsXPTType::T_WCHAR: *l_d = (uint64_t)l_s->val.wc;   break;
44 
45         case nsXPTType::T_DOUBLE:
46             *((double*)l_d) = l_s->val.d;
47             if(fpCount < 13)
48                 l_fprData[fpCount++] = l_s->val.d;
49             break;
50         case nsXPTType::T_FLOAT:
51             *((float*)l_d) = l_s->val.f;
52             if(fpCount < 13)
53                 l_fprData[fpCount++] = l_s->val.f;
54             break;
55         default:
56             // all the others are plain pointer types
57             *l_d = (uint64_t)l_s->val.p;
58             break;
59         }
60     }
61 }
62 #endif
63