expr.c (expand_expr_real_1): Just use do_store_flag.
[official-gcc.git] / libgomp / testsuite / libgomp.c / sections-1.c
blob3a6584cb71816490c1171236227cf7ceddd5792a
1 /* Test that all sections are touched. */
3 /* { dg-require-effective-target sync_int_long } */
5 #include <omp.h>
6 #include <string.h>
7 #include <assert.h>
8 #include "libgomp_g.h"
11 #define N 100
12 static int data[N];
13 static int NTHR;
15 static void clean_data (void)
17 memset (data, -1, sizeof (data));
20 static void test_data (void)
22 int i;
24 for (i = 0; i < N; ++i)
25 assert (data[i] != -1);
28 static void set_data (unsigned i, int val)
30 int old;
31 assert (i >= 1 && i <= N);
32 old = __sync_lock_test_and_set (data+i-1, val);
33 assert (old == -1);
37 static void f_1 (void *dummy)
39 int iam = omp_get_thread_num ();
40 unsigned long s;
42 for (s = GOMP_sections_start (N); s ; s = GOMP_sections_next ())
43 set_data (s, iam);
44 GOMP_sections_end ();
47 static void test_1 (void)
49 clean_data ();
50 GOMP_parallel_start (f_1, NULL, NTHR);
51 f_1 (NULL);
52 GOMP_parallel_end ();
53 test_data ();
56 static void f_2 (void *dummy)
58 int iam = omp_get_thread_num ();
59 unsigned s;
61 while ((s = GOMP_sections_next ()))
62 set_data (s, iam);
63 GOMP_sections_end_nowait ();
66 static void test_2 (void)
68 clean_data ();
69 GOMP_parallel_sections_start (f_2, NULL, NTHR, N);
70 f_2 (NULL);
71 GOMP_parallel_end ();
72 test_data ();
75 int main()
77 omp_set_dynamic (0);
79 NTHR = 4;
81 test_1 ();
82 test_2 ();
84 return 0;