2013-02-04 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / libsanitizer / tsan / tsan_interface_inl.h
blob133348a942caa906150c374187075e5cd7d8ada2
1 //===-- tsan_interface_inl.h ------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of ThreadSanitizer (TSan), a race detector.
9 //
10 //===----------------------------------------------------------------------===//
12 #include "tsan_interface.h"
13 #include "tsan_rtl.h"
15 #define CALLERPC ((uptr)__builtin_return_address(0))
17 using namespace __tsan; // NOLINT
19 void __tsan_read1(void *addr) {
20 MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 0, 0);
23 void __tsan_read2(void *addr) {
24 MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 1, 0);
27 void __tsan_read4(void *addr) {
28 MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 2, 0);
31 void __tsan_read8(void *addr) {
32 MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 3, 0);
35 void __tsan_write1(void *addr) {
36 MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 0, 1);
39 void __tsan_write2(void *addr) {
40 MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 1, 1);
43 void __tsan_write4(void *addr) {
44 MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 2, 1);
47 void __tsan_write8(void *addr) {
48 MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 3, 1);
51 void __tsan_vptr_update(void **vptr_p, void *new_val) {
52 CHECK_EQ(sizeof(vptr_p), 8);
53 if (*vptr_p != new_val)
54 MemoryAccess(cur_thread(), CALLERPC, (uptr)vptr_p, 3, 1);
57 void __tsan_func_entry(void *pc) {
58 FuncEntry(cur_thread(), (uptr)pc);
61 void __tsan_func_exit() {
62 FuncExit(cur_thread());
65 void __tsan_read_range(void *addr, uptr size) {
66 MemoryAccessRange(cur_thread(), CALLERPC, (uptr)addr, size, false);
69 void __tsan_write_range(void *addr, uptr size) {
70 MemoryAccessRange(cur_thread(), CALLERPC, (uptr)addr, size, true);