1 /* Test __atomic routines for existence and proper execution on 4 byte
2    values with each valid memory model.  */
3 /* { dg-do run } */
4 /* { dg-require-effective-target sync_int_long } */
5 
6 /* Test the execution of the __atomic_store_n builtin for an int.  */
7 
8 extern void abort(void);
9 
10 int v, count;
11 
main()12 main ()
13 {
14   v = 0;
15   count = 0;
16 
17   __atomic_store_n (&v, count + 1, __ATOMIC_RELAXED);
18   if (v != ++count)
19     abort ();
20 
21   __atomic_store_n (&v, count + 1, __ATOMIC_RELEASE);
22   if (v != ++count)
23     abort ();
24 
25   __atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST);
26   if (v != ++count)
27     abort ();
28 
29   /* Now test the generic variant.  */
30   count++;
31 
32   __atomic_store (&v, &count, __ATOMIC_RELAXED);
33   if (v != count++)
34     abort ();
35 
36   __atomic_store (&v, &count, __ATOMIC_RELEASE);
37   if (v != count++)
38     abort ();
39 
40   __atomic_store (&v, &count, __ATOMIC_SEQ_CST);
41   if (v != count)
42     abort ();
43 
44 
45   return 0;
46 }
47 
48