atomic-store-4.c 905 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Test __atomic routines for existence and proper execution on 8 byte
  2. values with each valid memory model. */
  3. /* { dg-do run } */
  4. /* { dg-options "" } */
  5. /* Test the execution of the __atomic_store_n builtin for a long long. */
  6. extern void abort(void);
  7. long long v, count;
  8. int
  9. main ()
  10. {
  11. v = 0;
  12. count = 0;
  13. __atomic_store_n (&v, count + 1, __ATOMIC_RELAXED);
  14. if (v != ++count)
  15. abort ();
  16. __atomic_store_n (&v, count + 1, __ATOMIC_RELEASE);
  17. if (v != ++count)
  18. abort ();
  19. __atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST);
  20. if (v != ++count)
  21. abort ();
  22. /* Now test the generic variant. */
  23. count++;
  24. __atomic_store (&v, &count, __ATOMIC_RELAXED);
  25. if (v != count++)
  26. abort ();
  27. __atomic_store (&v, &count, __ATOMIC_RELEASE);
  28. if (v != count++)
  29. abort ();
  30. __atomic_store (&v, &count, __ATOMIC_SEQ_CST);
  31. if (v != count)
  32. abort ();
  33. return 0;
  34. }