Skip gnat.dg/prot7.adb on hppa.
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / task-detach-13.c
blob9622fd8251f0cbb6fc81feff8461ad1f6f55118e
1 /* { dg-do run { target *-*-linux* *-*-gnu* *-*-freebsd* } } */
2 /* { dg-timeout 10 } */
4 /* Test that omp_fulfill_event works when called from an external
5 non-OpenMP thread. */
7 #include <omp.h>
8 #include <unistd.h>
9 #include <pthread.h>
10 #include <stdio.h>
12 int finished = 0;
13 int event_pending = 0;
14 omp_event_handle_t detach_event;
16 void *
17 fulfill_thread (void *)
19 while (!__atomic_load_n (&finished, __ATOMIC_RELAXED))
21 if (__atomic_load_n (&event_pending, __ATOMIC_ACQUIRE))
23 omp_fulfill_event (detach_event);
24 __atomic_store_n (&event_pending, 0, __ATOMIC_RELEASE);
27 sleep(1);
30 return 0;
33 int
34 main (void)
36 pthread_t thr;
37 int dep;
38 pthread_create (&thr, NULL, fulfill_thread, 0);
40 #pragma omp parallel
41 #pragma omp single
43 omp_event_handle_t ev;
45 #pragma omp task depend (out: dep) detach (ev)
47 detach_event = ev;
48 __atomic_store_n (&event_pending, 1, __ATOMIC_RELEASE);
51 #pragma omp task depend (in: dep)
53 __atomic_store_n (&finished, 1, __ATOMIC_RELAXED);
57 pthread_join (thr, 0);
58 return 0;