aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libgomp/testsuite/libgomp.c++/cancel-test.h
blob: 776d6ee6321dbed23df40cf8514f9a47a78a0c2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdlib.h>
#include <omp.h>

struct S
{
  static int s;
  int v;
  S ()
  {
    #pragma omp atomic
    s++;
  }

  S (int x)
  {
    #pragma omp atomic
    s++;
    v = x;
  }

  ~S ()
  {
    #pragma omp atomic
    s--;
  }

  S (const S &x)
  {
    #pragma omp atomic
    s++;
    v = x.v;
  }

  static void
  verify ()
  {
    if (s) abort ();
  }

  void
  bump ()
  {
    v++;
  }
};

int S::s = 0;