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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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 /* Implement shared vtbl methods. */
     8 #include "xptcprivate.h"
    10 #if !defined(__NetBSD__) || !defined(__m68k__)
    11 #error This code is for NetBSD/m68k only
    12 #endif
    14 extern "C" {
    15     static nsresult ATTRIBUTE_USED
    16     PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
    17     {
    18 #define PARAM_BUFFER_COUNT     16
    20         nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    21         nsXPTCMiniVariant* dispatchParams = nullptr;
    22         nsIInterfaceInfo* iface_info = nullptr;
    23         const nsXPTMethodInfo* info;
    24         uint8_t paramCount;
    25         uint8_t i;
    26         nsresult result = NS_ERROR_FAILURE;
    28         NS_ASSERTION(self,"no self");
    30         self->GetInterfaceInfo(&iface_info);
    31         NS_ASSERTION(iface_info,"no interface info");
    33         iface_info->GetMethodInfo(uint16_t(methodIndex), &info);
    34         NS_ASSERTION(info,"no interface info");
    36         paramCount = info->GetParamCount();
    38         // setup variant array pointer
    39         if(paramCount > PARAM_BUFFER_COUNT)
    40             dispatchParams = new nsXPTCMiniVariant[paramCount];
    41         else
    42             dispatchParams = paramBuffer;
    43         NS_ASSERTION(dispatchParams,"no place for params");
    45         uint32_t* ap = args;
    46         for(i = 0; i < paramCount; i++, ap++)
    47         {
    48             const nsXPTParamInfo& param = info->GetParam(i);
    49             const nsXPTType& type = param.GetType();
    50             nsXPTCMiniVariant* dp = &dispatchParams[i];
    52             if(param.IsOut() || !type.IsArithmetic())
    53             {
    54                 dp->val.p = (void*) *ap;
    55                 continue;
    56             }
    58             switch(type)
    59             {
    60             // the 8 and 16 bit types will have been promoted to 32 bits before
    61             // being pushed onto the stack. Since the 68k is big endian, we
    62             // need to skip over the leading high order bytes.
    63             case nsXPTType::T_I8     : dp->val.i8  = *(((int8_t*) ap) + 3);  break;
    64             case nsXPTType::T_I16    : dp->val.i16 = *(((int16_t*) ap) + 1); break;
    65             case nsXPTType::T_I32    : dp->val.i32 = *((int32_t*) ap);       break;
    66             case nsXPTType::T_I64    : dp->val.i64 = *((int64_t*) ap); ap++; break;
    67             case nsXPTType::T_U8     : dp->val.u8  = *(((uint8_t*) ap) + 3); break;
    68             case nsXPTType::T_U16    : dp->val.u16 = *(((uint16_t*)ap) + 1); break;
    69             case nsXPTType::T_U32    : dp->val.u32 = *((uint32_t*)ap);       break;
    70             case nsXPTType::T_U64    : dp->val.u64 = *((uint64_t*)ap); ap++; break;
    71             case nsXPTType::T_FLOAT  : dp->val.f   = *((float*)   ap);       break;
    72             case nsXPTType::T_DOUBLE : dp->val.d   = *((double*)  ap); ap++; break;
    73             case nsXPTType::T_BOOL   : dp->val.b   = *(((char*)   ap) + 3);  break;
    74             case nsXPTType::T_CHAR   : dp->val.c   = *(((char*)   ap) + 3);  break;
    75             // wchar_t is an int (32 bits) on NetBSD
    76             case nsXPTType::T_WCHAR  : dp->val.wc  = *((wchar_t*) ap);       break;
    77             default:
    78                 NS_ERROR("bad type");
    79                 break;
    80             }
    81         }
    83         result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams);
    85         NS_RELEASE(iface_info);
    87         if(dispatchParams != paramBuffer)
    88             delete [] dispatchParams;
    90         return result;
    91     }
    92 }
    94 #define STUB_ENTRY(n)							\
    95 __asm__(								\
    96     ".global	_Stub"#n"__14nsXPTCStubBase\n\t"			\
    97 "_Stub"#n"__14nsXPTCStubBase:\n\t"					\
    98     "link  a6,#0			\n\t"				\
    99     "lea   a6@(12), a0			\n\t"	/* pointer to args */	\
   100     "movl  a0, sp@-			\n\t"				\
   101     "movl  #"#n", sp@-			\n\t"	/* method index */	\
   102     "movl  a6@(8), sp@-			\n\t"	/* this */		\
   103     "jbsr  _PrepareAndDispatch		\n\t"				\
   104     "unlk  a6				\n\t"				\
   105     "rts				\n\t"				\
   106 );
   108 #define SENTINEL_ENTRY(n) \
   109 nsresult nsXPTCStubBase::Sentinel##n() \
   110 { \
   111     NS_ERROR("nsXPTCStubBase::Sentinel called"); \
   112     return NS_ERROR_NOT_IMPLEMENTED; \
   113 }
   115 #include "xptcstubsdef.inc"

mercurial