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"
13 #include "gtest/gtest.h"
20 llvm::ManagedStatic<int> ms;
27 TEST(Initialize, MultipleThreads) {
28 // Run this test under tsan: http://code.google.com/p/data-race-test/
30 llvm_start_multithreaded();
32 pthread_create(&t1, NULL, test1::helper, NULL);
33 pthread_create(&t2, NULL, test1::helper, NULL);
34 pthread_join(t1, NULL);
35 pthread_join(t2, NULL);
36 llvm_stop_multithreaded();
39 } // anonymous namespace