• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- tsan_interface_inl.h ------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of ThreadSanitizer (TSan), a race detector.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "tsan_interface.h"
15 #include "tsan_rtl.h"
16 
17 #define CALLERPC ((uptr)__builtin_return_address(0))
18 
19 using namespace __tsan;  // NOLINT
20 
__tsan_read1(void * addr)21 void __tsan_read1(void *addr) {
22   MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 0, 0);
23 }
24 
__tsan_read2(void * addr)25 void __tsan_read2(void *addr) {
26   MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 1, 0);
27 }
28 
__tsan_read4(void * addr)29 void __tsan_read4(void *addr) {
30   MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 2, 0);
31 }
32 
__tsan_read8(void * addr)33 void __tsan_read8(void *addr) {
34   MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 3, 0);
35 }
36 
__tsan_write1(void * addr)37 void __tsan_write1(void *addr) {
38   MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 0, 1);
39 }
40 
__tsan_write2(void * addr)41 void __tsan_write2(void *addr) {
42   MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 1, 1);
43 }
44 
__tsan_write4(void * addr)45 void __tsan_write4(void *addr) {
46   MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 2, 1);
47 }
48 
__tsan_write8(void * addr)49 void __tsan_write8(void *addr) {
50   MemoryAccess(cur_thread(), CALLERPC, (uptr)addr, 3, 1);
51 }
52 
__tsan_vptr_update(void ** vptr_p,void * new_val)53 void __tsan_vptr_update(void **vptr_p, void *new_val) {
54   CHECK_EQ(sizeof(vptr_p), 8);
55   if (*vptr_p != new_val)
56     MemoryAccess(cur_thread(), CALLERPC, (uptr)vptr_p, 3, 1);
57 }
58 
__tsan_func_entry(void * pc)59 void __tsan_func_entry(void *pc) {
60   FuncEntry(cur_thread(), (uptr)pc);
61 }
62 
__tsan_func_exit()63 void __tsan_func_exit() {
64   FuncExit(cur_thread());
65 }
66