1 //===- llvm/unittest/Support/ManagedStatic.cpp - ManagedStatic tests ------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/ManagedStatic.h"
10 #include "llvm/Support/Threading.h"
11 #include "llvm/Config/config.h"
16 #include "gtest/gtest.h"
24 llvm::ManagedStatic<int> ms;
31 TEST(Initialize, MultipleThreads) {
32 // Run this test under tsan: http://code.google.com/p/data-race-test/
34 llvm_start_multithreaded();
36 pthread_create(&t1, NULL, test1::helper, NULL);
37 pthread_create(&t2, NULL, test1::helper, NULL);
38 pthread_join(t1, NULL);
39 pthread_join(t2, NULL);
40 llvm_stop_multithreaded();
44 } // anonymous namespace