[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / openmp / runtime / test / api / kmp_set_defaults_lock_bug.c
blob73a7afb8113f852a51ee05faa94bc138127a257d
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include "omp_testsuite.h"
4 /* The bug occurs if the lock table is reallocated after
5 kmp_set_defaults() is called. If the table is reallocated,
6 then the lock will not point to a valid lock object after the
7 kmp_set_defaults() call.*/
8 omp_lock_t lock;
10 int test_kmp_set_defaults_lock_bug()
12 /* checks that omp_get_num_threads is equal to the number of
13 threads */
14 int nthreads_lib;
15 int nthreads = 0;
17 nthreads_lib = -1;
19 #pragma omp parallel
21 omp_set_lock(&lock);
22 nthreads++;
23 omp_unset_lock(&lock);
24 #pragma omp single
26 nthreads_lib = omp_get_num_threads ();
27 } /* end of single */
28 } /* end of parallel */
29 kmp_set_defaults("OMP_NUM_THREADS");
30 #pragma omp parallel
32 omp_set_lock(&lock);
33 nthreads++;
34 omp_unset_lock(&lock);
35 } /* end of parallel */
37 return (nthreads == 2*nthreads_lib);
40 int main()
42 int i;
43 int num_failed=0;
44 omp_init_lock(&lock);
46 for(i = 0; i < REPETITIONS; i++) {
47 if(!test_kmp_set_defaults_lock_bug()) {
48 num_failed++;
51 omp_destroy_lock(&lock);
52 return num_failed;