Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: src/ports/SkBarriers_tsan.h

Issue 306373002: Add SkBarriers_tsan.h. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: elif Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPostConfig.h ('k') | tools/tsan.supp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 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 */
7
8 #ifndef SkBarriers_tsan_DEFINED
9 #define SkBarriers_tsan_DEFINED
10
11 #include <sanitizer/tsan_interface_atomic.h>
12
13 static inline void sk_compiler_barrier() { asm volatile("" : : : "memory"); }
14
15 // We'd do this as separate functions, but you can't partially specialize functi ons...
16 template <typename T, size_t bits>
17 struct SkBarriers {
18 static T AcquireLoad(T*);
19 static void ReleaseStore(T*, T);
20 };
21
22 #define SK_BARRIERS(BITS) \
23 template <typename T> \
24 struct SkBarriers<T, BITS> { \
25 static T AcquireLoad(T* ptr) { \
26 return (T)__tsan_atomic ## BITS ## _load((__tsan_atomic ## BITS*)ptr , \
27 __tsan_memory_order_acquire ); \
28 } \
29 static void ReleaseStore(T* ptr, T val) { \
30 __tsan_atomic ## BITS ## _store((__tsan_atomic ## BITS*)ptr, \
31 val, \
32 __tsan_memory_order_release); \
33 } \
34 }
35 SK_BARRIERS(8);
36 SK_BARRIERS(16);
37 SK_BARRIERS(32);
38 SK_BARRIERS(64);
39 #undef SK_BARRIERS
40
41 template <typename T>
42 T sk_acquire_load(T* ptr) { return SkBarriers<T, 8*sizeof(T)>::AcquireLoad(ptr); }
43
44 template <typename T>
45 void sk_release_store(T* ptr, T val) { SkBarriers<T, 8*sizeof(T)>::ReleaseStore( ptr, val); }
46
47
48 #endif//SkBarriers_tsan_DEFINED
OLDNEW
« no previous file with comments | « include/core/SkPostConfig.h ('k') | tools/tsan.supp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698