CheckAtomic.cmake 354 B

123456789101112131415161718192021222324252627
  1. include(CheckCSourceCompiles)
  2. if(USE_DOUBLE)
  3. set(type "int64_t")
  4. else()
  5. set(type "int32_t")
  6. endif()
  7. check_c_source_compiles("
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. int main() {
  11. static volatile ${type} val = 0;
  12. ${type} u = __sync_add_and_fetch(&val, 1);
  13. if(u - 1 == 0) {
  14. return 0;
  15. }
  16. return 1;
  17. }
  18. " HAVE_ATOMIC_BUILTIN)