Rebase.
[official-gcc.git] / libgomp / testsuite / libgomp.c / lock-1.c
blobe09645dbc3f451359c5a6fa951d4378bc6da7e1f
1 #include <omp.h>
2 #include <stdlib.h>
4 int
5 main (void)
7 int l = 0;
8 omp_nest_lock_t lock;
9 omp_init_nest_lock (&lock);
10 if (omp_test_nest_lock (&lock) != 1)
11 abort ();
12 if (omp_test_nest_lock (&lock) != 2)
13 abort ();
14 #pragma omp parallel if (0) reduction (+:l)
16 /* In OpenMP 2.5 this was supposed to return 3,
17 but in OpenMP 3.0 the parallel region has a different
18 task and omp_*_lock_t are owned by tasks, not by threads. */
19 if (omp_test_nest_lock (&lock) != 0)
20 l++;
22 if (l)
23 abort ();
24 if (omp_test_nest_lock (&lock) != 3)
25 abort ();
26 omp_unset_nest_lock (&lock);
27 omp_unset_nest_lock (&lock);
28 omp_unset_nest_lock (&lock);
29 omp_destroy_nest_lock (&lock);
30 return 0;