2
0

ax_atomic.m4 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # AC_C___ATOMIC
  2. # -------------
  3. # Define HAVE_C___ATOMIC if __atomic works.
  4. AN_IDENTIFIER([__atomic], [AC_C___ATOMIC])
  5. AC_DEFUN([AC_C___ATOMIC],
  6. [AC_CACHE_CHECK([for __atomic], ac_cv_c___atomic,
  7. [AC_LINK_IFELSE(
  8. [AC_LANG_SOURCE(
  9. [[int
  10. main (int argc, char **argv)
  11. {
  12. volatile unsigned long ul1 = 1;
  13. unsigned long ul2 = 0, ul3 = 2;
  14. __atomic_load_n(&ul1, __ATOMIC_SEQ_CST);
  15. __atomic_compare_exchange(&ul1, &ul2, &ul3, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
  16. __atomic_fetch_add(&ul1, 1, __ATOMIC_SEQ_CST);
  17. __atomic_fetch_sub(&ul1, 1, __ATOMIC_SEQ_CST);
  18. __atomic_or_fetch(&ul1, ul2, __ATOMIC_SEQ_CST);
  19. __atomic_and_fetch(&ul1, ul2, __ATOMIC_SEQ_CST);
  20. volatile unsigned long long ull1 = 1;
  21. unsigned long long ull2 = 0, ull3 = 2;
  22. __atomic_load_n(&ull1, __ATOMIC_SEQ_CST);
  23. __atomic_compare_exchange(&ull1, &ull2, &ull3, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
  24. __atomic_fetch_add(&ull1, 1, __ATOMIC_SEQ_CST);
  25. __atomic_fetch_sub(&ull1, 1, __ATOMIC_SEQ_CST);
  26. __atomic_or_fetch(&ull1, ull2, __ATOMIC_SEQ_CST);
  27. __atomic_and_fetch(&ull1, ull2, __ATOMIC_SEQ_CST);
  28. return 0;
  29. }
  30. ]])],
  31. [ac_cv_c___atomic=yes],
  32. [ac_cv_c___atomic=no])])
  33. if test $ac_cv_c___atomic = yes; then
  34. AC_DEFINE([HAVE_C___ATOMIC], 1,
  35. [Define to 1 if __atomic operations work.])
  36. AM_CFLAGS="$AM_CFLAGS -DHAVE_C___ATOMIC=1"
  37. fi
  38. ])# AC_C___ATOMIC