• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _UNIFIED_ANNOTATIONS_H_
2 #define _UNIFIED_ANNOTATIONS_H_
3 
4 
5 #include "../../drd/drd.h"
6 
7 
8 /*
9  * Define annotation macros such that these can be intercepted by DRD, Helgrind
10  * and ThreadSanitizer. See also
11  * http://code.google.com/p/data-race-test/source/browse/trunk/dynamic_annotations/dynamic_annotations.h
12  */
13 #define U_ANNOTATE_NEW_MEMORY(addr, size) ANNOTATE_NEW_MEMORY(addr, size)
14 #define U_ANNOTATE_HAPPENS_BEFORE(addr) U_AnnotateHappensBefore(addr)
15 #define U_ANNOTATE_HAPPENS_AFTER(addr) U_AnnotateHappensAfter(addr)
16 #define U_ANNOTATE_HAPPENS_DONE(addr)		\
17   do {						\
18     ANNOTATE_HAPPENS_DONE(addr);		\
19   } while(0)
20 
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 #if 0
26 }
27 #endif
28 
29 
30 void  __attribute__((weak,noinline))
AnnotateCondVarSignal(const char * file,int line,const volatile void * cv)31 AnnotateCondVarSignal(const char *file, int line, const volatile void *cv)
32 {
33   asm("");
34 }
35 
36 void  __attribute__((weak,noinline))
AnnotateCondVarWait(const char * file,int line,const volatile void * cv,const volatile void * lock)37 AnnotateCondVarWait(const char *file, int line, const volatile void *cv,
38 		    const volatile void *lock)
39 {
40   asm("");
41 }
42 
U_AnnotateHappensBefore(void * addr)43 static __inline__ void U_AnnotateHappensBefore(void* addr)
44 {
45   ANNOTATE_HAPPENS_BEFORE(addr);
46   AnnotateCondVarSignal(__FILE__, __LINE__, addr);
47 }
48 
U_AnnotateHappensAfter(void * addr)49 static __inline__ void U_AnnotateHappensAfter(void *addr)
50 {
51   ANNOTATE_HAPPENS_AFTER(addr);
52   AnnotateCondVarWait(__FILE__, __LINE__, addr, NULL);
53 }
54 
55 
56 #if 0
57 {
58 #endif
59 #ifdef __cplusplus
60 }
61 #endif
62 
63 
64 #endif /* _UNIFIED_ANNOTATIONS_H_ */
65