Sat, 03 Jan 2015 20:18:00 +0100
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 /* Platform specific code to invoke XPCOM methods on native objects */
8 #include "xptcprivate.h"
10 // Remember that these 'words' are 32bit DWORDS
12 #if !defined(__NetBSD__) || !defined(__m68k__)
13 #error This code is for NetBSD/m68k only
14 #endif
16 extern "C" {
17 static uint32_t
18 invoke_count_words(uint32_t paramCount, nsXPTCVariant* s)
19 {
20 uint32_t result = 0;
21 for(uint32_t i = 0; i < paramCount; i++, s++)
22 {
23 if(s->IsPtrData())
24 {
25 result++;
26 continue;
27 }
28 switch(s->type)
29 {
30 case nsXPTType::T_I8 :
31 case nsXPTType::T_I16 :
32 case nsXPTType::T_I32 :
33 result++;
34 break;
35 case nsXPTType::T_I64 :
36 result+=2;
37 break;
38 case nsXPTType::T_U8 :
39 case nsXPTType::T_U16 :
40 case nsXPTType::T_U32 :
41 result++;
42 break;
43 case nsXPTType::T_U64 :
44 result+=2;
45 break;
46 case nsXPTType::T_FLOAT :
47 result++;
48 break;
49 case nsXPTType::T_DOUBLE :
50 result+=2;
51 break;
52 case nsXPTType::T_BOOL :
53 case nsXPTType::T_CHAR :
54 case nsXPTType::T_WCHAR :
55 result++;
56 break;
57 default:
58 // all the others are plain pointer types
59 result++;
60 break;
61 }
62 }
63 return result;
64 }
66 static void
67 invoke_copy_to_stack(uint32_t* d, uint32_t paramCount, nsXPTCVariant* s)
68 {
69 for(uint32_t i = 0; i < paramCount; i++, d++, s++)
70 {
71 if(s->IsPtrData())
72 {
73 *((void**)d) = s->ptr;
74 continue;
75 }
76 switch(s->type)
77 {
78 // 8 and 16 bit types should be promoted to 32 bits when copying
79 // onto the stack.
80 case nsXPTType::T_I8 : *((uint32_t*)d) = s->val.i8; break;
81 case nsXPTType::T_I16 : *((uint32_t*)d) = s->val.i16; break;
82 case nsXPTType::T_I32 : *((int32_t*) d) = s->val.i32; break;
83 case nsXPTType::T_I64 : *((int64_t*) d) = s->val.i64; d++; break;
84 case nsXPTType::T_U8 : *((uint32_t*)d) = s->val.u8; break;
85 case nsXPTType::T_U16 : *((uint32_t*)d) = s->val.u16; break;
86 case nsXPTType::T_U32 : *((uint32_t*)d) = s->val.u32; break;
87 case nsXPTType::T_U64 : *((uint64_t*)d) = s->val.u64; d++; break;
88 case nsXPTType::T_FLOAT : *((float*) d) = s->val.f; break;
89 case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d; d++; break;
90 case nsXPTType::T_BOOL : *((uint32_t*)d) = s->val.b; break;
91 case nsXPTType::T_CHAR : *((uint32_t*)d) = s->val.c; break;
92 // wchar_t is an int (32 bits) on NetBSD
93 case nsXPTType::T_WCHAR : *((wchar_t*) d) = s->val.wc; break;
94 default:
95 // all the others are plain pointer types
96 *((void**)d) = s->val.p;
97 break;
98 }
99 }
100 }
101 }
103 XPTC_PUBLIC_API(nsresult)
104 XPTC_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
105 uint32_t paramCount, nsXPTCVariant* params)
106 {
107 uint32_t result;
109 __asm__ __volatile__(
110 "movl %4, sp@-\n\t"
111 "movl %3, sp@-\n\t"
112 "jbsr _invoke_count_words\n\t" /* count words */
113 "addql #8, sp\n\t"
114 "lsll #2, d0\n\t" /* *= 4 */
115 "movl sp, a2\n\t" /* save original sp */
116 "subl d0, sp\n\t" /* make room for params */
117 "movl sp, a0\n\t"
118 "movl %4, sp@-\n\t"
119 "movl %3, sp@-\n\t"
120 "movl a0, sp@-\n\t"
121 "jbsr _invoke_copy_to_stack\n\t" /* copy params */
122 "addl #12, sp\n\t"
123 "movl %1, a0\n\t"
124 "movl a0@, a1\n\t"
125 "movl %2, d0\n\t" /* function index */
126 "movl a0, d1\n\t"
127 "movw a1@(8,d0:l:8), a0\n\t"
128 "addl a0, d1\n\t"
129 "movl a1@(12,d0:l:8), a1\n\t"
130 "movl d1, sp@-\n\t"
131 "jbsr a1@\n\t"
132 "movl a2, sp\n\t" /* restore original sp */
133 "movl d0, %0\n\t"
134 : "=g" (result) /* %0 */
135 : "g" (that), /* %1 */
136 "g" (methodIndex), /* %2 */
137 "g" (paramCount), /* %3 */
138 "g" (params) /* %4 */
139 : "a0", "a1", "a2", "d0", "d1", "memory"
140 );
142 return result;
143 }