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 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
8 #ifndef SkAtomics_sync_DEFINED
9 #define SkAtomics_sync_DEFINED
11 /** GCC/Clang __sync based atomics. */
13 #include <stdint.h>
15 static inline __attribute__((always_inline)) int32_t sk_atomic_inc(int32_t* addr) {
16 return __sync_fetch_and_add(addr, 1);
17 }
19 static inline __attribute__((always_inline)) int32_t sk_atomic_add(int32_t* addr, int32_t inc) {
20 return __sync_fetch_and_add(addr, inc);
21 }
23 static inline __attribute__((always_inline)) int32_t sk_atomic_dec(int32_t* addr) {
24 return __sync_fetch_and_add(addr, -1);
25 }
27 static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomic_dec() { }
29 static inline __attribute__((always_inline)) int32_t sk_atomic_conditional_inc(int32_t* addr) {
30 int32_t value = *addr;
32 while (true) {
33 if (value == 0) {
34 return 0;
35 }
37 int32_t before = __sync_val_compare_and_swap(addr, value, value + 1);
39 if (before == value) {
40 return value;
41 } else {
42 value = before;
43 }
44 }
45 }
47 static inline __attribute__((always_inline)) bool sk_atomic_cas(int32_t* addr,
48 int32_t before,
49 int32_t after) {
50 return __sync_bool_compare_and_swap(addr, before, after);
51 }
53 static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomic_conditional_inc() { }
55 #endif