• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- tsan_interface.cc -------------------------------------------------===//
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_interface_ann.h"
16 #include "tsan_rtl.h"
17 
18 #define CALLERPC ((uptr)__builtin_return_address(0))
19 
20 using namespace __tsan;  // NOLINT
21 
__tsan_init()22 void __tsan_init() {
23   Initialize(cur_thread());
24 }
25 
__tsan_read16(void * addr)26 void __tsan_read16(void *addr) {
27   MemoryRead8Byte(cur_thread(), CALLERPC, (uptr)addr);
28   MemoryRead8Byte(cur_thread(), CALLERPC, (uptr)addr + 8);
29 }
30 
__tsan_write16(void * addr)31 void __tsan_write16(void *addr) {
32   MemoryWrite8Byte(cur_thread(), CALLERPC, (uptr)addr);
33   MemoryWrite8Byte(cur_thread(), CALLERPC, (uptr)addr + 8);
34 }
35 
__tsan_acquire(void * addr)36 void __tsan_acquire(void *addr) {
37   Acquire(cur_thread(), CALLERPC, (uptr)addr);
38 }
39 
__tsan_release(void * addr)40 void __tsan_release(void *addr) {
41   Release(cur_thread(), CALLERPC, (uptr)addr);
42 }
43