1 // This file is used from other tests.
9 typedef MyObject
*MyObjectRef
;
11 void InitializeLibrary();
12 MyObject
*ObjectCreate();
13 long ObjectRead(MyObject
*);
14 void ObjectWrite(MyObject
*, long);
15 void ObjectWriteAnother(MyObject
*, long);
23 #if defined(USE_TSAN_CALLBACKS)
25 void *(*callback_register_tag
)(const char *object_type
);
26 void *(*callback_assign_tag
)(void *addr
, void *tag
);
27 void (*callback_read
)(void *addr
, void *caller_pc
, void *tag
);
28 void (*callback_write
)(void *addr
, void *caller_pc
, void *tag
);
31 void InitializeLibrary() {
32 #if defined(USE_TSAN_CALLBACKS)
33 callback_register_tag
= (decltype(callback_register_tag
))dlsym(RTLD_DEFAULT
, "__tsan_external_register_tag");
34 callback_assign_tag
= (decltype(callback_assign_tag
))dlsym(RTLD_DEFAULT
, "__tsan_external_assign_tag");
35 callback_read
= (decltype(callback_read
))dlsym(RTLD_DEFAULT
, "__tsan_external_read");
36 callback_write
= (decltype(callback_write
))dlsym(RTLD_DEFAULT
, "__tsan_external_write");
37 tag
= callback_register_tag("MyLibrary::MyObject");
41 MyObject
*ObjectCreate() {
42 MyObject
*ref
= (MyObject
*)malloc(sizeof(MyObject
));
43 #if defined(USE_TSAN_CALLBACKS)
44 callback_assign_tag(ref
, tag
);
49 long ObjectRead(MyObject
*ref
) {
50 #if defined(USE_TSAN_CALLBACKS)
51 callback_read(ref
, __builtin_return_address(0), tag
);
56 void ObjectWrite(MyObject
*ref
, long val
) {
57 #if defined(USE_TSAN_CALLBACKS)
58 callback_write(ref
, __builtin_return_address(0), tag
);
63 void ObjectWriteAnother(MyObject
*ref
, long val
) {
64 #if defined(USE_TSAN_CALLBACKS)
65 callback_write(ref
, __builtin_return_address(0), tag
);