atomic-load-2.c 1.1 KB

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