xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_aix.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial