// RUN: %t.so && \
// RUN: %clang_tsan -O1 %s %t.so -o %t && %run %t 2>&1 | FileCheck %s
#include <sanitizer/tsan_interface.h>
#include <stdio.h>
#if BUILD_SO
volatile int counter = 0;
volatile int lib_constructor_call = 0;
volatile int tsan_init_call = 0;
__attribute__ ((constructor))
void LibConstructor() {
lib_constructor_call = ++counter;
};
#else
extern int counter;
extern int lib_constructor_call;
extern int tsan_init_call;
volatile int bin_constructor_call = 0;
__attribute__ ((constructor))
void BinConstructor() {
bin_constructor_call = ++counter;
};
namespace __tsan {
void OnInitialize() {
tsan_init_call = ++counter;
}
}
int main() {
printf("TSAN_INIT %d\n", tsan_init_call);
printf("LIB_CONSTRUCTOR %d\n", lib_constructor_call);
printf("BIN_CONSTRUCTOR %d\n", bin_constructor_call);
return 0;
}
#endif