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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /* Implement shared vtbl methods. */
michael@0 7
michael@0 8 #include "xptcprivate.h"
michael@0 9
michael@0 10 #if defined(sparc) || defined(__sparc__)
michael@0 11
michael@0 12 extern "C" nsresult ATTRIBUTE_USED
michael@0 13 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
michael@0 14 {
michael@0 15
michael@0 16 typedef struct {
michael@0 17 uint32_t hi;
michael@0 18 uint32_t lo;
michael@0 19 } DU; // have to move 64 bit entities as 32 bit halves since
michael@0 20 // stack slots are not guaranteed 16 byte aligned
michael@0 21
michael@0 22 #define PARAM_BUFFER_COUNT 16
michael@0 23
michael@0 24 nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
michael@0 25 nsXPTCMiniVariant* dispatchParams = nullptr;
michael@0 26 nsIInterfaceInfo* iface_info = nullptr;
michael@0 27 const nsXPTMethodInfo* info;
michael@0 28 uint8_t paramCount;
michael@0 29 uint8_t i;
michael@0 30 nsresult result = NS_ERROR_FAILURE;
michael@0 31
michael@0 32 NS_ASSERTION(self,"no self");
michael@0 33
michael@0 34 self->GetInterfaceInfo(&iface_info);
michael@0 35 NS_ASSERTION(iface_info,"no interface info");
michael@0 36
michael@0 37 iface_info->GetMethodInfo(uint16_t(methodIndex), &info);
michael@0 38 NS_ASSERTION(info,"no interface info");
michael@0 39
michael@0 40 paramCount = info->GetParamCount();
michael@0 41
michael@0 42 // setup variant array pointer
michael@0 43 if(paramCount > PARAM_BUFFER_COUNT)
michael@0 44 dispatchParams = new nsXPTCMiniVariant[paramCount];
michael@0 45 else
michael@0 46 dispatchParams = paramBuffer;
michael@0 47 NS_ASSERTION(dispatchParams,"no place for params");
michael@0 48
michael@0 49 uint32_t* ap = args;
michael@0 50 for(i = 0; i < paramCount; i++, ap++)
michael@0 51 {
michael@0 52 const nsXPTParamInfo& param = info->GetParam(i);
michael@0 53 const nsXPTType& type = param.GetType();
michael@0 54 nsXPTCMiniVariant* dp = &dispatchParams[i];
michael@0 55
michael@0 56 if(param.IsOut() || !type.IsArithmetic())
michael@0 57 {
michael@0 58 dp->val.p = (void*) *ap;
michael@0 59 continue;
michael@0 60 }
michael@0 61 // else
michael@0 62 switch(type)
michael@0 63 {
michael@0 64 case nsXPTType::T_I8 : dp->val.i8 = *((int32_t*) ap); break;
michael@0 65 case nsXPTType::T_I16 : dp->val.i16 = *((int32_t*) ap); break;
michael@0 66 case nsXPTType::T_I32 : dp->val.i32 = *((int32_t*) ap); break;
michael@0 67 case nsXPTType::T_DOUBLE :
michael@0 68 case nsXPTType::T_U64 :
michael@0 69 case nsXPTType::T_I64 : ((DU *)dp)->hi = ((DU *)ap)->hi;
michael@0 70 ((DU *)dp)->lo = ((DU *)ap)->lo;
michael@0 71 ap++;
michael@0 72 break;
michael@0 73 case nsXPTType::T_U8 : dp->val.u8 = *((uint32_t*)ap); break;
michael@0 74 case nsXPTType::T_U16 : dp->val.u16 = *((uint32_t*)ap); break;
michael@0 75 case nsXPTType::T_U32 : dp->val.u32 = *((uint32_t*)ap); break;
michael@0 76 case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
michael@0 77 case nsXPTType::T_BOOL : dp->val.b = *((uint32_t*)ap); break;
michael@0 78 case nsXPTType::T_CHAR : dp->val.c = *((uint32_t*)ap); break;
michael@0 79 case nsXPTType::T_WCHAR : dp->val.wc = *((int32_t*) ap); break;
michael@0 80 default:
michael@0 81 NS_ERROR("bad type");
michael@0 82 break;
michael@0 83 }
michael@0 84 }
michael@0 85
michael@0 86 result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams);
michael@0 87
michael@0 88 NS_RELEASE(iface_info);
michael@0 89
michael@0 90 if(dispatchParams != paramBuffer)
michael@0 91 delete [] dispatchParams;
michael@0 92
michael@0 93 return result;
michael@0 94 }
michael@0 95
michael@0 96 extern "C" nsresult SharedStub(int, int*);
michael@0 97
michael@0 98 #define STUB_ENTRY(n) \
michael@0 99 nsresult nsXPTCStubBase::Stub##n() \
michael@0 100 { \
michael@0 101 int dummy; /* defeat tail-call optimization */ \
michael@0 102 return SharedStub(n, &dummy); \
michael@0 103 }
michael@0 104
michael@0 105 #define SENTINEL_ENTRY(n) \
michael@0 106 nsresult nsXPTCStubBase::Sentinel##n() \
michael@0 107 { \
michael@0 108 NS_ERROR("nsXPTCStubBase::Sentinel called"); \
michael@0 109 return NS_ERROR_NOT_IMPLEMENTED; \
michael@0 110 }
michael@0 111
michael@0 112 #include "xptcstubsdef.inc"
michael@0 113
michael@0 114 #endif /* sparc || __sparc__ */

mercurial