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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_aix.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/* Platform specific code to invoke XPCOM methods on native objects */
    1.10 +
    1.11 +#include "xptcprivate.h"
    1.12 +
    1.13 +#ifndef AIX
    1.14 +#error "This code is for PowerPC only"
    1.15 +#endif
    1.16 +
    1.17 +extern "C" void
    1.18 +invoke_copy_to_stack(uint32_t* d, uint32_t paramCount, nsXPTCVariant* s, double *fprData)
    1.19 +{
    1.20 +/*
    1.21 +    We need to copy the parameters for this function to locals and use them
    1.22 +    from there since the parameters occupy the same stack space as the stack
    1.23 +    we're trying to populate.
    1.24 +*/
    1.25 +    uint32_t *l_d = d;
    1.26 +    nsXPTCVariant *l_s = s;
    1.27 +    uint32_t l_paramCount = paramCount, fpCount = 0;
    1.28 +    double *l_fprData = fprData;
    1.29 +
    1.30 +    typedef struct {
    1.31 +        uint32_t hi;
    1.32 +        uint32_t lo;
    1.33 +    } DU;               // have to move 64 bit entities as 32 bit halves since
    1.34 +                        // stack slots are not guaranteed 16 byte aligned
    1.35 +
    1.36 +    for(uint32_t i = 0; i < l_paramCount; i++, l_d++, l_s++)
    1.37 +    {
    1.38 +        if(l_s->IsPtrData())
    1.39 +        {
    1.40 +            *((void**)l_d) = l_s->ptr;
    1.41 +            continue;
    1.42 +        }
    1.43 +        switch(l_s->type)
    1.44 +        {
    1.45 +        case nsXPTType::T_I8     : *((int32_t*)  l_d) = l_s->val.i8;          break;
    1.46 +        case nsXPTType::T_I16    : *((int32_t*)  l_d) = l_s->val.i16;         break;
    1.47 +        case nsXPTType::T_I32    : *((int32_t*)  l_d) = l_s->val.i32;         break;
    1.48 +        case nsXPTType::T_I64    : 
    1.49 +        case nsXPTType::T_U64    :
    1.50 +            *((uint32_t*) l_d++) = ((DU *)l_s)->hi;
    1.51 +            *((uint32_t*) l_d) = ((DU *)l_s)->lo;
    1.52 +            break;
    1.53 +        case nsXPTType::T_DOUBLE :
    1.54 +            *((uint32_t*) l_d++) = ((DU *)l_s)->hi;
    1.55 +            *((uint32_t*) l_d) = ((DU *)l_s)->lo;
    1.56 +            if(fpCount < 13)
    1.57 +                l_fprData[fpCount++] = l_s->val.d;
    1.58 +            break;
    1.59 +        case nsXPTType::T_U8     : *((uint32_t*) l_d) = l_s->val.u8;          break;
    1.60 +        case nsXPTType::T_U16    : *((uint32_t*) l_d) = l_s->val.u16;         break;
    1.61 +        case nsXPTType::T_U32    : *((uint32_t*) l_d) = l_s->val.u32;         break;
    1.62 +        case nsXPTType::T_FLOAT  :
    1.63 +            *((float*)  l_d) = l_s->val.f;
    1.64 +            if(fpCount < 13)
    1.65 +                l_fprData[fpCount++] = l_s->val.f;
    1.66 +            break;
    1.67 +        case nsXPTType::T_BOOL   : *((uint32_t*) l_d) = l_s->val.b;           break;
    1.68 +        case nsXPTType::T_CHAR   : *((uint32_t*) l_d) = l_s->val.c;           break;
    1.69 +        case nsXPTType::T_WCHAR  : *((int32_t*)  l_d) = l_s->val.wc;          break;
    1.70 +        default:
    1.71 +            // all the others are plain pointer types
    1.72 +            *((void**)l_d) = l_s->val.p;
    1.73 +            break;
    1.74 +        }
    1.75 +    }
    1.76 +}
    1.77 +

mercurial