atomic-2.c 562 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* { dg-do run } */
  2. /* { dg-additional-options "-mcx16" { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
  3. #ifdef __x86_64__
  4. #include "cpuid.h"
  5. #endif
  6. double d = 1.5;
  7. long double ld = 3;
  8. extern void abort (void);
  9. void
  10. test (void)
  11. {
  12. #pragma omp atomic
  13. d *= 1.25;
  14. #pragma omp atomic
  15. ld /= 0.75;
  16. if (d != 1.875 || ld != 4.0L)
  17. abort ();
  18. }
  19. int
  20. main (void)
  21. {
  22. #ifdef __x86_64__
  23. unsigned int eax, ebx, ecx, edx;
  24. if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
  25. return 0;
  26. if (!(ecx & bit_CMPXCHG16B))
  27. return 0;
  28. #endif
  29. test ();
  30. return 0;
  31. }