pandora_have_gcc_atomics.m4 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. dnl Copyright (C) 2009 Sun Microsystems, Inc.
  2. dnl This file is free software; Sun Microsystems, Inc.
  3. dnl gives unlimited permission to copy and/or distribute it,
  4. dnl with or without modifications, as long as this notice is preserved.
  5. #--------------------------------------------------------------------
  6. # Check for GCC Atomic Support
  7. #--------------------------------------------------------------------
  8. AC_DEFUN([PANDORA_HAVE_GCC_ATOMICS],[
  9. AC_CACHE_CHECK(
  10. [whether the compiler provides atomic builtins],
  11. [ac_cv_gcc_atomic_builtins],
  12. [AC_LINK_IFELSE(
  13. [AC_LANG_PROGRAM([],[[
  14. int foo= -10; int bar= 10;
  15. if (!__sync_fetch_and_add(&foo, bar) || foo)
  16. return -1;
  17. bar= __sync_lock_test_and_set(&foo, bar);
  18. if (bar || foo != 10)
  19. return -1;
  20. bar= __sync_val_compare_and_swap(&bar, foo, 15);
  21. if (bar)
  22. return -1;
  23. return 0;
  24. ]])],
  25. [ac_cv_gcc_atomic_builtins=yes],
  26. [ac_cv_gcc_atomic_builtins=no])])
  27. AS_IF([test "x$ac_cv_gcc_atomic_builtins" = "xyes"],[
  28. AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS, 1,
  29. [Define to 1 if compiler provides atomic builtins.])
  30. ])
  31. ])