testsuite/libgomp.c/lock-1.c

Go to the documentation of this file.
00001 #include <omp.h>
00002 #include <stdlib.h>
00003 
00004 int
00005 main (void)
00006 {
00007   int l = 0;
00008   omp_nest_lock_t lock;
00009   omp_init_nest_lock (&lock);
00010   if (omp_test_nest_lock (&lock) != 1)
00011     abort ();
00012   if (omp_test_nest_lock (&lock) != 2)
00013     abort ();
00014 #pragma omp parallel if (0) reduction (+:l)
00015   {
00016     /* In OpenMP 2.5 this was supposed to return 3,
00017        but in OpenMP 3.0 the parallel region has a different
00018        task and omp_*_lock_t are owned by tasks, not by threads.  */
00019     if (omp_test_nest_lock (&lock) != 0)
00020       l++;
00021   }
00022   if (l)
00023     abort ();
00024   if (omp_test_nest_lock (&lock) != 3)
00025     abort ();
00026   omp_unset_nest_lock (&lock);
00027   omp_unset_nest_lock (&lock);
00028   omp_unset_nest_lock (&lock);
00029   omp_destroy_nest_lock (&lock);
00030   return 0;
00031 }

Generated on Fri Apr 5 05:38:10 2013 for Libgomp by  doxygen 1.4.7