xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc_netbsd.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/xptcstubs_sparc_netbsd.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,114 @@
     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 +/* Implement shared vtbl methods. */
    1.10 +
    1.11 +#include "xptcprivate.h"
    1.12 +
    1.13 +#if defined(sparc) || defined(__sparc__)
    1.14 +
    1.15 +extern "C" nsresult ATTRIBUTE_USED
    1.16 +PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
    1.17 +{
    1.18 +
    1.19 +    typedef struct {
    1.20 +        uint32_t hi;
    1.21 +        uint32_t lo;
    1.22 +    } DU;               // have to move 64 bit entities as 32 bit halves since
    1.23 +                        // stack slots are not guaranteed 16 byte aligned
    1.24 +
    1.25 +#define PARAM_BUFFER_COUNT     16
    1.26 +
    1.27 +    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    1.28 +    nsXPTCMiniVariant* dispatchParams = nullptr;
    1.29 +    nsIInterfaceInfo* iface_info = nullptr;
    1.30 +    const nsXPTMethodInfo* info;
    1.31 +    uint8_t paramCount;
    1.32 +    uint8_t i;
    1.33 +    nsresult result = NS_ERROR_FAILURE;
    1.34 +
    1.35 +    NS_ASSERTION(self,"no self");
    1.36 +
    1.37 +    self->GetInterfaceInfo(&iface_info);
    1.38 +    NS_ASSERTION(iface_info,"no interface info");
    1.39 +
    1.40 +    iface_info->GetMethodInfo(uint16_t(methodIndex), &info);
    1.41 +    NS_ASSERTION(info,"no interface info");
    1.42 +
    1.43 +    paramCount = info->GetParamCount();
    1.44 +
    1.45 +    // setup variant array pointer
    1.46 +    if(paramCount > PARAM_BUFFER_COUNT)
    1.47 +        dispatchParams = new nsXPTCMiniVariant[paramCount];
    1.48 +    else
    1.49 +        dispatchParams = paramBuffer;
    1.50 +    NS_ASSERTION(dispatchParams,"no place for params");
    1.51 +
    1.52 +    uint32_t* ap = args;
    1.53 +    for(i = 0; i < paramCount; i++, ap++)
    1.54 +    {
    1.55 +        const nsXPTParamInfo& param = info->GetParam(i);
    1.56 +        const nsXPTType& type = param.GetType();
    1.57 +        nsXPTCMiniVariant* dp = &dispatchParams[i];
    1.58 +
    1.59 +        if(param.IsOut() || !type.IsArithmetic())
    1.60 +        {
    1.61 +            dp->val.p = (void*) *ap;
    1.62 +            continue;
    1.63 +        }
    1.64 +        // else
    1.65 +        switch(type)
    1.66 +        {
    1.67 +        case nsXPTType::T_I8     : dp->val.i8  = *((int32_t*)  ap);       break;
    1.68 +        case nsXPTType::T_I16    : dp->val.i16 = *((int32_t*) ap);       break;
    1.69 +        case nsXPTType::T_I32    : dp->val.i32 = *((int32_t*) ap);       break;
    1.70 +        case nsXPTType::T_DOUBLE :
    1.71 +        case nsXPTType::T_U64    :
    1.72 +        case nsXPTType::T_I64    : ((DU *)dp)->hi = ((DU *)ap)->hi; 
    1.73 +                                   ((DU *)dp)->lo = ((DU *)ap)->lo;
    1.74 +                                   ap++;
    1.75 +                                   break;
    1.76 +        case nsXPTType::T_U8     : dp->val.u8  = *((uint32_t*)ap);       break;
    1.77 +        case nsXPTType::T_U16    : dp->val.u16 = *((uint32_t*)ap);       break;
    1.78 +        case nsXPTType::T_U32    : dp->val.u32 = *((uint32_t*)ap);       break;
    1.79 +        case nsXPTType::T_FLOAT  : dp->val.f   = *((float*)   ap);       break;
    1.80 +        case nsXPTType::T_BOOL   : dp->val.b   = *((uint32_t*)ap);       break;
    1.81 +        case nsXPTType::T_CHAR   : dp->val.c   = *((uint32_t*)ap);       break;
    1.82 +        case nsXPTType::T_WCHAR  : dp->val.wc  = *((int32_t*) ap);       break;
    1.83 +        default:
    1.84 +            NS_ERROR("bad type");
    1.85 +            break;
    1.86 +        }
    1.87 +    }
    1.88 +
    1.89 +    result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams);
    1.90 +
    1.91 +    NS_RELEASE(iface_info);
    1.92 +
    1.93 +    if(dispatchParams != paramBuffer)
    1.94 +        delete [] dispatchParams;
    1.95 +
    1.96 +    return result;
    1.97 +}
    1.98 +
    1.99 +extern "C" nsresult SharedStub(int, int*);
   1.100 +
   1.101 +#define STUB_ENTRY(n) \
   1.102 +nsresult nsXPTCStubBase::Stub##n() \
   1.103 +{ \
   1.104 +	int dummy; /* defeat tail-call optimization */ \
   1.105 +	return SharedStub(n, &dummy); \
   1.106 +}
   1.107 +
   1.108 +#define SENTINEL_ENTRY(n) \
   1.109 +nsresult nsXPTCStubBase::Sentinel##n() \
   1.110 +{ \
   1.111 +    NS_ERROR("nsXPTCStubBase::Sentinel called"); \
   1.112 +    return NS_ERROR_NOT_IMPLEMENTED; \
   1.113 +}
   1.114 +
   1.115 +#include "xptcstubsdef.inc"
   1.116 +
   1.117 +#endif /* sparc || __sparc__ */

mercurial