summaryrefslogtreecommitdiff
path: root/libitm/testsuite/libitm.c/simple-2.c
diff options
context:
space:
mode:
Diffstat (limited to 'libitm/testsuite/libitm.c/simple-2.c')
-rw-r--r--libitm/testsuite/libitm.c/simple-2.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libitm/testsuite/libitm.c/simple-2.c b/libitm/testsuite/libitm.c/simple-2.c
new file mode 100644
index 00000000000..e92c917340d
--- /dev/null
+++ b/libitm/testsuite/libitm.c/simple-2.c
@@ -0,0 +1,29 @@
+/* Simplest test involving real threads. Verify we get the correct answer. */
+
+#include <stdlib.h>
+#include <pthread.h>
+
+static int x;
+
+static void *start (void *dummy __attribute__((unused)))
+{
+ __transaction_atomic { x++; }
+ return NULL;
+}
+
+int main()
+{
+ pthread_t p[10];
+ int i;
+
+ for (i = 0; i < 10; ++i)
+ pthread_create (p+i, NULL, start, NULL);
+
+ for (i = 0; i < 10; ++i)
+ pthread_join (p[i], NULL);
+
+ if (x != 10)
+ abort ();
+
+ return 0;
+}