diff --git a/test/mini-apps/concurrent-inc/CMakeLists.txt b/test/mini-apps/concurrent-inc/CMakeLists.txt index 6dd74b6..0b0e893 100644 --- a/test/mini-apps/concurrent-inc/CMakeLists.txt +++ b/test/mini-apps/concurrent-inc/CMakeLists.txt @@ -4,6 +4,12 @@ add_executable(${EXAMPLE} "main") target_link_libraries(${EXAMPLE} Threads::Threads) set_target_properties(${EXAMPLE} PROPERTIES CXX_STANDARD 11) +add_executable("${EXAMPLE}-static" "main") +target_link_libraries("${EXAMPLE}-static" Threads::Threads) +set_target_properties("${EXAMPLE}-static" PROPERTIES CXX_STANDARD 11) +target_compile_definitions("${EXAMPLE}-static" PRIVATE USE_STATIC) + if(DRACE_INSTALL_TESTS) install(TARGETS ${EXAMPLE} DESTINATION ${DRACE_RUNTIME_DEST}) + install(TARGETS "${EXAMPLE}-static" DESTINATION ${DRACE_RUNTIME_DEST}) endif() diff --git a/test/mini-apps/concurrent-inc/main.cpp b/test/mini-apps/concurrent-inc/main.cpp index 9677155..ffca434 100644 --- a/test/mini-apps/concurrent-inc/main.cpp +++ b/test/mini-apps/concurrent-inc/main.cpp @@ -1,7 +1,7 @@ /* * DRace, a dynamic data race detector * - * Copyright 2018 Siemens AG + * Copyright 2020 Siemens AG * * Authors: * Felix Moessbauer @@ -14,9 +14,9 @@ #include #define NUM_INCREMENTS 10000 -#define USE_HEAP -// std::mutex mx; +// #define USE_HEAP // race on the heap +// #define USE_STATIC // race on a static variable void inc(int* v) { for (int i = 0; i < NUM_INCREMENTS; ++i) { @@ -39,6 +39,9 @@ int main() { #ifdef USE_HEAP int* mem = new int[1]; *mem = 0; +#elif USE_STATIC + static int var = 0; + int* mem = &var; #else int var = 0; int* mem = &var;