DRD: Add test program for std::thread.

To do: document _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE/AFTER in the DRD manual.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12284
This commit is contained in:
Bart Van Assche
2011-12-10 19:42:05 +00:00
parent a70a467080
commit aac70d3117
5 changed files with 88 additions and 0 deletions

23
drd/tests/std_thread.cpp Normal file
View File

@@ -0,0 +1,23 @@
// Test whether no race conditions are reported on std::thread. Note: since
// the implementation of std::thread uses the shared pointer implementation,
// that implementation has to be annotated in order to avoid false positives.
// See also http://gcc.gnu.org/onlinedocs/libstdc++/manual/debug.html for more
// information.
#include "../../drd/drd.h"
#define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(addr) \
ANNOTATE_HAPPENS_BEFORE(addr)
#define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(addr) \
ANNOTATE_HAPPENS_AFTER(addr)
#define _GLIBCXX_EXTERN_TEMPLATE -1
#include <iostream>
#include <thread>
int main(int argc, char** argv)
{
std::thread t( []() { } );
t.join();
std::cerr << "Done.\n";
return 0;
}