sigalrm.vgtest \
sigaltstack.stderr.exp \
sigaltstack.vgtest \
+ std_atomic.stderr.exp \
+ std_atomic.vgtest \
std_list.stderr.exp \
std_list.vgtest \
std_string.stderr.exp \
if CXX_CAN_INCLUDE_THREAD_HEADER
if HAVE_SHARED_POINTER_ANNOTATION
check_PROGRAMS += \
+ std_atomic \
std_list \
std_string \
std_thread
matinv_LDADD = $(LDADD) -lm
endif
+std_atomic_SOURCES = std_atomic.cpp
+std_atomic_CXXFLAGS = $(AM_CXXFLAGS) -std=c++0x -Wno-sign-compare
+
std_list_SOURCES = std_list.cpp
std_list_CXXFLAGS = $(AM_CXXFLAGS) -std=c++0x -Wno-sign-compare
--- /dev/null
+/*
+ * Test program for std::atomic<>
+ *
+ * See also https://bugs.kde.org/show_bug.cgi?id=328490.
+ */
+
+#include "../drd.h"
+#include <atomic>
+#include <iostream>
+#include <string>
+#include <pthread.h>
+
+std::atomic<bool> g_b;
+
+void *func1(void *instance)
+{
+ while (!g_b) {
+ timespec delay = { 0, 100 * 1000 * 1000 };
+ nanosleep(&delay, NULL);
+ }
+ return NULL;
+}
+
+void *func2(void *instance)
+{
+ g_b = true;
+ return NULL;
+}
+
+int main(int argc, char* argv[])
+{
+ int err;
+ pthread_t thread1;
+ pthread_t thread2;
+
+ std::cerr << "Started.\n";
+
+ if (argc > 1)
+ DRD_IGNORE_VAR(g_b);
+
+ err = pthread_create(&thread1, NULL, &func1, NULL);
+ if (err != 0)
+ throw std::string("failed to create a thread.");
+ err = pthread_create(&thread2, NULL, &func2, NULL);
+ if (err != 0)
+ throw std::string("failed to create a thread.");
+
+ err = pthread_join(thread1, NULL);
+ if (err != 0)
+ throw std::string("Thread::join(): failed to join.");
+ err = pthread_join(thread2, NULL);
+ if (err != 0)
+ throw std::string("Thread::join(): failed to join.");
+
+ std::cerr << "Done.\n";
+}