void test_atomic_bool (_Atomic _Bool *a) { enum { SEQ_CST = __ATOMIC_SEQ_CST }; __atomic_fetch_add (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_add." } */ __atomic_fetch_sub (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_sub." } */ __atomic_fetch_and (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_and." } */ __atomic_fetch_xor (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_xor." } */ __atomic_fetch_or (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_or." } */ __atomic_fetch_nand (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_nand." } */ __atomic_add_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_add_fetch." } */ __atomic_sub_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_sub_fetch." } */ __atomic_and_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_and_fetch." } */ __atomic_xor_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_xor_fetch." } */ __atomic_or_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_or_fetch." } */ __atomic_nand_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_nand_fetch." } */ /* The following are valid and must be accepted. */ _Bool val = 0, ret = 0; __atomic_exchange (a, &val, &ret, SEQ_CST); __atomic_exchange_n (a, val, SEQ_CST); __atomic_compare_exchange (a, &val, &ret, !1, SEQ_CST, SEQ_CST); __atomic_compare_exchange_n (a, &val, ret, !1, SEQ_CST, SEQ_CST); __atomic_test_and_set (a, SEQ_CST); __atomic_clear (a, SEQ_CST); }
static inline void free_lock (void *addr, int model) { bool *lock_ptr = __libatomic_flag_for_address (addr); __atomic_clear (lock_ptr, __ATOMIC_RELEASE); maybe_acquire_fence (model); }
main () { bool b; __atomic_clear (&a, __ATOMIC_RELAXED); if (a != 0) abort (); b = __atomic_test_and_set (&a, __ATOMIC_SEQ_CST); if (a != 1 || b != 0) abort (); b = __atomic_test_and_set (&a, __ATOMIC_ACQ_REL); if (b != 1 || a != 1) abort (); __atomic_clear (&a, __ATOMIC_SEQ_CST); if (a != 0) abort (); return 0; }
main () { int b; __atomic_clear (&a, __ATOMIC_RELAXED); if (a != 0) abort (); b = __atomic_test_and_set (&a, __ATOMIC_SEQ_CST); if (a != __GCC_ATOMIC_TEST_AND_SET_TRUEVAL || b != 0) abort (); b = __atomic_test_and_set (&a, __ATOMIC_ACQ_REL); if (a != __GCC_ATOMIC_TEST_AND_SET_TRUEVAL || b != 1) abort (); __atomic_clear (&a, __ATOMIC_SEQ_CST); if (a != 0) abort (); return 0; }