void test_or () { v = 0; count = 1; __atomic_or_fetch (&v, count, __ATOMIC_RELAXED); if (v != 1) abort (); count *= 2; __atomic_fetch_or (&v, count, __ATOMIC_CONSUME); if (v != 3) abort (); count *= 2; __atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE); if (v != 7) abort (); count *= 2; __atomic_fetch_or (&v, 8, __ATOMIC_RELEASE); if (v != 15) abort (); count *= 2; __atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL); if (v != 31) abort (); count *= 2; __atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST); if (v != 63) abort (); }
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); }
void test_or_fetch () { v = 0; count = 1; if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1) abort (); count *= 2; if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3) abort (); count *= 2; if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7) abort (); count *= 2; if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15) abort (); count *= 2; if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31) abort (); count *= 2; if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63) abort (); }
static INLINE int tcache_get(const struct timeval *const tv, struct tm *const tm) { unsigned mode; mode = __atomic_load_n(&g_tcache_mode, __ATOMIC_RELAXED); if (0 == (mode & TCACHE_FLUID)) { mode = __atomic_fetch_add(&g_tcache_mode, 1, __ATOMIC_ACQUIRE); if (0 == (mode & TCACHE_FLUID)) { if (g_tcache_tv.tv_sec == tv->tv_sec) { *tm = g_tcache_tm; __atomic_sub_fetch(&g_tcache_mode, 1, __ATOMIC_RELEASE); return !0; } __atomic_or_fetch(&g_tcache_mode, TCACHE_STALE, __ATOMIC_RELAXED); } __atomic_sub_fetch(&g_tcache_mode, 1, __ATOMIC_RELEASE); } return 0; }
int atomic_or_fetch_CONSUME () { return __atomic_or_fetch (&v, 4096, __ATOMIC_CONSUME); }
void cnn_data_set_evaluated_bit(CNNData* data, unsigned char bit) { __atomic_or_fetch(&data->evaluated, BIT(bit), __ATOMIC_RELEASE); event_count_broadcast(&data->event_counts[bit]); }