Daily bump.
[official-gcc.git] / libsanitizer / tsan / tsan_interface_java.h
blob885ff28975115ed0a48d139e3b009252968cb635
1 //===-- tsan_interface_java.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 // Interface for verification of Java or mixed Java/C++ programs.
11 // The interface is intended to be used from within a JVM and notify TSan
12 // about such events like Java locks and GC memory compaction.
14 // For plain memory accesses and function entry/exit a JVM is intended to use
15 // C++ interfaces: __tsan_readN/writeN and __tsan_func_enter/exit.
17 // For volatile memory accesses and atomic operations JVM is intended to use
18 // standard atomics API: __tsan_atomicN_load/store/etc.
20 // For usage examples see lit_tests/java_*.cc
21 //===----------------------------------------------------------------------===//
22 #ifndef TSAN_INTERFACE_JAVA_H
23 #define TSAN_INTERFACE_JAVA_H
25 #ifndef INTERFACE_ATTRIBUTE
26 # define INTERFACE_ATTRIBUTE __attribute__((visibility("default")))
27 #endif
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 typedef unsigned long jptr; // NOLINT
35 // Must be called before any other callback from Java.
36 void __tsan_java_init(jptr heap_begin, jptr heap_size) INTERFACE_ATTRIBUTE;
37 // Must be called when the application exits.
38 // Not necessary the last callback (concurrently running threads are OK).
39 // Returns exit status or 0 if tsan does not want to override it.
40 int __tsan_java_fini() INTERFACE_ATTRIBUTE;
42 // Callback for memory allocations.
43 // May be omitted for allocations that are not subject to data races
44 // nor contain synchronization objects (e.g. String).
45 void __tsan_java_alloc(jptr ptr, jptr size) INTERFACE_ATTRIBUTE;
46 // Callback for memory free.
47 // Can be aggregated for several objects (preferably).
48 void __tsan_java_free(jptr ptr, jptr size) INTERFACE_ATTRIBUTE;
49 // Callback for memory move by GC.
50 // Can be aggregated for several objects (preferably).
51 // The ranges must not overlap.
52 void __tsan_java_move(jptr src, jptr dst, jptr size) INTERFACE_ATTRIBUTE;
54 // Mutex lock.
55 // Addr is any unique address associated with the mutex.
56 // Can be called on recursive reentry.
57 void __tsan_java_mutex_lock(jptr addr) INTERFACE_ATTRIBUTE;
58 // Mutex unlock.
59 void __tsan_java_mutex_unlock(jptr addr) INTERFACE_ATTRIBUTE;
60 // Mutex read lock.
61 void __tsan_java_mutex_read_lock(jptr addr) INTERFACE_ATTRIBUTE;
62 // Mutex read unlock.
63 void __tsan_java_mutex_read_unlock(jptr addr) INTERFACE_ATTRIBUTE;
64 // Recursive mutex lock, intended for handling of Object.wait().
65 // The 'rec' value must be obtained from the previous
66 // __tsan_java_mutex_unlock_rec().
67 void __tsan_java_mutex_lock_rec(jptr addr, int rec) INTERFACE_ATTRIBUTE;
68 // Recursive mutex unlock, intended for handling of Object.wait().
69 // The return value says how many times this thread called lock()
70 // w/o a pairing unlock() (i.e. how many recursive levels it unlocked).
71 // It must be passed back to __tsan_java_mutex_lock_rec() to restore
72 // the same recursion level.
73 int __tsan_java_mutex_unlock_rec(jptr addr) INTERFACE_ATTRIBUTE;
75 #ifdef __cplusplus
76 } // extern "C"
77 #endif
79 #undef INTERFACE_ATTRIBUTE
81 #endif // #ifndef TSAN_INTERFACE_JAVA_H