cmake HAVE_GCC_ATOMIC_BUILTINS examples

CUBRID/cubrid CMakeLists.txt :560

check_c_source_compiles("#include <stdint.h>
int main() {
  uint64_t i, j, r;
  i = 100; j = 200; r = __sync_bool_compare_and_swap(&i, 100, j);
  if (r == 0 || i != 200) { return(1); }
  i = 100; j = 200; r = __sync_bool_compare_and_swap(&i, 101, j);
  if (r != 0 || i != 100) { return(1); }
  i = 100; j = 200; r = __sync_add_and_fetch(&i, j);
  if (r != 300 || i != 300) { return(1); }
  i = 100; r = __sync_lock_test_and_set(&i, 200);
  if (r != 100 || i != 200) { return(1); }
  return(0);
}"
  HAVE_GCC_ATOMIC_BUILTINS)

arkdb/inception configure.cmake :1014

CHECK_CXX_SOURCE_COMPILES("
  int main()
  {
    int foo= -10; int bar= 10;
    long long int foo64= -10; long long int bar64= 10;
    if (!__sync_fetch_and_add(&foo, bar) || foo)
      return -1;
    bar= __sync_lock_test_and_set(&foo, bar);
    if (bar || foo != 10)
      return -1;
    bar= __sync_val_compare_and_swap(&bar, foo, 15);
    if (bar)
      return -1;
    if (!__sync_fetch_and_add(&foo64, bar64) || foo64)
      return -1;
    bar64= __sync_lock_test_and_set(&foo64, bar64);
    if (bar64 || foo64 != 10)
      return -1;
    bar64= __sync_val_compare_and_swap(&bar64, foo, 15);
    if (bar64)
      return -1;
    return 0;
  }"
  HAVE_GCC_ATOMIC_BUILTINS)

google/mysql-protobuf configure.cmake :717

CHECK_CXX_SOURCE_COMPILES("
  int main()
  {
    int foo= -10; int bar= 10;
    long long int foo64= -10; long long int bar64= 10;
    if (!__sync_fetch_and_add(&foo, bar) || foo)
      return -1;
    bar= __sync_lock_test_and_set(&foo, bar);
    if (bar || foo != 10)
      return -1;
    bar= __sync_val_compare_and_swap(&bar, foo, 15);
    if (bar)
      return -1;
    if (!__sync_fetch_and_add(&foo64, bar64) || foo64)
      return -1;
    bar64= __sync_lock_test_and_set(&foo64, bar64);
    if (bar64 || foo64 != 10)
      return -1;
    bar64= __sync_val_compare_and_swap(&bar64, foo, 15);
    if (bar64)
      return -1;
    return 0;
  }"
  HAVE_GCC_ATOMIC_BUILTINS)

alibaba/AliSQL configure.cmake :1123

CHECK_CXX_SOURCE_COMPILES("
  int main()
  {
    int foo= -10; int bar= 10;
    long long int foo64= -10; long long int bar64= 10;
    if (!__sync_fetch_and_add(&foo, bar) || foo)
      return -1;
    bar= __sync_lock_test_and_set(&foo, bar);
    if (bar || foo != 10)
      return -1;
    bar= __sync_val_compare_and_swap(&bar, foo, 15);
    if (bar)
      return -1;
    if (!__sync_fetch_and_add(&foo64, bar64) || foo64)
      return -1;
    bar64= __sync_lock_test_and_set(&foo64, bar64);
    if (bar64 || foo64 != 10)
      return -1;
    bar64= __sync_val_compare_and_swap(&bar64, foo, 15);
    if (bar64)
      return -1;
    return 0;
  }"
  HAVE_GCC_ATOMIC_BUILTINS)

alibaba/AliSQL configure.cmake :1151

ENDIF(NOT HAVE_GCC_ATOMIC_BUILTINS)

mongodb/mongo-bi-connector-odbc-driver configure.cmake :744

CHECK_CXX_SOURCE_COMPILES("
  int main()
  {
    int foo= -10; int bar= 10;
    long long int foo64= -10; long long int bar64= 10;
    if (!__atomic_fetch_add(&foo, bar, __ATOMIC_SEQ_CST) || foo)
      return -1;
    bar= __atomic_exchange_n(&foo, bar, __ATOMIC_SEQ_CST);
    if (bar || foo != 10)
      return -1;
    bar= __atomic_compare_exchange_n(&bar, &foo, 15, 0,
                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
    if (bar)
      return -1;
    if (!__atomic_fetch_add(&foo64, bar64, __ATOMIC_SEQ_CST) || foo64)
      return -1;
    bar64= __atomic_exchange_n(&foo64, bar64, __ATOMIC_SEQ_CST);
    if (bar64 || foo64 != 10)
      return -1;
    bar64= __atomic_compare_exchange_n(&bar64, &foo64, 15, 0,
                                       __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
    if (bar64)
      return -1;
    return 0;
  }"
  HAVE_GCC_ATOMIC_BUILTINS)

Tokutek/mysql-5.5 configure.cmake :978

CHECK_CXX_SOURCE_COMPILES("
  int main()
  {
    int foo= -10; int bar= 10;
    long long int foo64= -10; long long int bar64= 10;
    if (!__sync_fetch_and_add(&foo, bar) || foo)
      return -1;
    bar= __sync_lock_test_and_set(&foo, bar);
    if (bar || foo != 10)
      return -1;
    bar= __sync_val_compare_and_swap(&bar, foo, 15);
    if (bar)
      return -1;
    if (!__sync_fetch_and_add(&foo64, bar64) || foo64)
      return -1;
    bar64= __sync_lock_test_and_set(&foo64, bar64);
    if (bar64 || foo64 != 10)
      return -1;
    bar64= __sync_val_compare_and_swap(&bar64, foo, 15);
    if (bar64)
      return -1;
    return 0;
  }"
  HAVE_GCC_ATOMIC_BUILTINS)