* c-cppbuiltin.c (c_cpp_builtins): Use ggc_strdup for the fp_suffix
[official-gcc.git] / libitm / testsuite / libitm.c++ / static_ctor.C
blob1420fd328efb4db91d373ab95593b5e7734d27d8
1 /* { dg-do run } */
2 /* { dg-options "-pthread" } */
3 /* { dg-skip-if "PR libitm/51822" { *-*-* } } */
4 /* Tests static constructors inside of transactional code.  */
6 #include <pthread.h>
7 #include <stdlib.h>
9 int f(int x) __attribute__((noinline,transaction_safe));
10 int f(int x)
12   static int y = x;
13   return y*x;
16 static void *thread (void *)
18   int bar;
19   __transaction_atomic { bar = f(10); }
20   if (bar != 100)
21     abort();
22   return 0;
25 int main()
27   int bar;
29   // First, initialize y in another thread.
30   pthread_t pt;
31   pthread_create(&pt, NULL, thread, NULL);
32   pthread_join(pt, NULL);
34   // Now y should already be initialized.
35   __transaction_atomic { bar = f(20); }
36   if (bar != 200)
37     abort();
39   return 0;